modiimedia/arri

Make error messages more transport agnostic

Closed this issue · 0 comments

Describe the feature
Right now the terminology around errors is intermingled with HTTP status codes. The data structures should be changed to be more transport agnostic while still being flexible enough to be used in whatever scenario.

This proposal would change the errors returned by the server from this:

interface ArriRequestError {
  statusCode: number;
  statusMessage: string;
  data?: any;
  stack?: string;
}

To this:

interface ArriError {
  code: number;
  message: string;
  data?: any;
  stack?: string;
}

In HTTP RPCS the code field will still match up with the HTTP status code but now if an alternative transport is used it's not bound to HTTP specific terminology.

Example HTTP Responses

404 Error

{ 
   "code": 404,
   "message": "Resource not found"
}

500 Error

{
  "code": 500,
  "message": "Internal server error"
}

Example Custom Transport Response

{
  "code": 41,
  "message": "Some custom error message"
}
{
  "code": 55,
  "message": "Some other custom error message"
}