[ADP-405] Inspiring HTTP Problem Redesign
Error Redesign
Let's redesign these non-standard configured errors in the RTSP client code base based on RFC9457 (HTTP Problem):
javascript
case 'Error: Access denied':
case 'Error: Streaming destroying':
case 'Error: The video codec has been changed.':
case 'Error: codec: H264 has been changed':
case 'Error: codec: HEVC has been changed':
case 'Error: Continuous play failed':
case 'Error: Unsupported MIME type':
case 'Error: codec: H265 is not supported':
case 'Error: codec: HEVC is not supported':
case 'Error: codec: JPEG is not supported':
case 'Error: 403':
case 'Error: 404':
case 'Error: RTSP error: 404 Not Found':
case 'Error: Failed to get stream.':
Redesigned error structure:
json
[
{
"type": "https://example.com/problems/access-denied",
"title": "Access Denied",
"status": 403,
"detail": "The client does not have access to the requested resource.",
"instance": "/streams/12345"
},
{
"type": "https://example.com/problems/streaming-destroying",
"title": "Streaming Destroying",
"status": 500,
"detail": "The streaming session is being destroyed due to an internal error.",
"instance": "/streams/12345"
},
{
"type": "https://example.com/problems/internal-server-error",
"title": "Internal Server Error",
"status": 500,
"detail": "An internal server error occurred.",
"instance": "/streams/12345"
},
{
"type": "https://example.com/problems/bad-request",
"title": "Bad Request",
"status": 400,
"detail": "The request was invalid or cannot be otherwise served.",
"instance": "/streams/12345"
},
{
"type": "https://example.com/problems/destination-unreachable",
"title": "Destination Unreachable",
"status": 404,
"detail": "The destination server could not be reached.",
"instance": "/streams/12345"
},
{
"type": "https://example.com/problems/continuous-play-failed",
"title": "Continuous Play Failed",
"status": 500,
"detail": "Continuous play of the stream failed due to an internal error.",
"instance": "/streams/12345"
},
{
"type": "https://example.com/problems/codec-not-supported",
"title": "Codec Not Supported",
"status": 415,
"detail": "The requested codec H265 is not supported.",
"instance": "/streams/12345"
},
{
"type": "https://example.com/problems/codec-not-supported",
"title": "Codec Not Supported",
"status": 415,
"detail": "The requested codec HEVC is not supported.",
"instance": "/streams/12345"
},
{
"type": "https://example.com/problems/codec-not-supported",
"title": "Codec Not Supported",
"status": 415,
"detail": "The requested codec JPEG is not supported.",
"instance": "/streams/12345"
},
{
"type": "https://example.com/problems/video-codec-changed",
"title": "Video Codec Changed",
"status": 409,
"detail": "The video codec has been changed.",
"instance": "/streams/12345"
},
{
"type": "https://example.com/problems/codec-changed",
"title": "Codec Changed",
"status": 409,
"detail": "The codec H264 has been changed.",
"instance": "/streams/12345"
},
{
"type": "https://example.com/problems/codec-changed",
"title": "Codec Changed",
"status": 409,
"detail": "The codec HEVC has been changed.",
"instance": "/streams/12345"
},
{
"type": "https://example.com/problems/unsupported-mime-type",
"title": "Unsupported MIME Type",
"status": 415,
"detail": "The requested MIME type is not supported.",
"instance": "/streams/12345"
},
{
"type": "https://example.com/problems/stream-not-found",
"title": "Stream Not Found",
"status": 404,
"detail": "The requested stream was not found.",
"instance": "/streams/12345"
},
{
"type": "https://example.com/problems/failed-to-get-stream",
"title": "Failed to Get Stream",
"status": 500,
"detail": "Failed to get the stream due to an internal error.",
"instance": "/streams/12345"
}
]
OpenAPI 3.1 Example
Here's an example of how to describe these errors using the OpenAPI 3.1 specification:
yaml
openapi: 3.1.0
info:
title: RTSP Client API
version: 1.0.0
components:
schemas:
Problem:
type: object
properties:
type:
type: string
format: uri
title:
type: string
status:
type: integer
detail:
type: string
instance:
type: string
format: uri-reference
required:
- type
- title
paths:
/streams/{streamId}:
get:
summary: Get stream
parameters:
- name: streamId
in: path
required: true
schema:
type: string
responses:
'200':
description: Successful response
'400':
description: Bad Request
content:
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
example:
type: https://example.com/problems/bad-request
title: Bad Request
status: 400
detail: The request was invalid or cannot be otherwise served.
instance: /streams/12345
'403':
description: Access Denied
content:
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
example:
type: https://example.com/problems/access-denied
title: Access Denied
status: 403
detail: The client does not have access to the requested resource.
instance: /streams/12345
'404':
description: Stream Not Found
content:
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
example:
type: https://example.com/problems/stream-not-found
title: Stream Not Found
status: 404
detail: The requested stream was not found.
instance: /streams/12345
'409':
description: Codec Changed
content:
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
example:
type: https://example.com/problems/codec-changed
title: Codec Changed
status: 409
detail: The codec H264 has been changed.
instance: /streams/12345
'415':
description: Unsupported Media Type
content:
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
example:
type: https://example.com/problems/codec-not-supported
title: Codec Not Supported
status: 415
detail: The requested codec H265 is not supported.
instance: /streams/12345
'500':
description: Internal Server Error
content:
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
example:
type: https://example.com/problems/internal-server-error
title: Internal Server Error
status: 500
detail: An internal server error occurred.
instance: /streams/12345