Skip to content

introduce configurable error handlers and default error handler for application/vnd.error+json #5

@mvcatsifma

Description

@mvcatsifma

Introduce a generic error handler for application/vnd.error+json, that publishes the error as an error object on the response:

Something along these lines:

factory('errorInterceptor', function ($q, HalError) {
  return {
    'responseError': function (response) {
      if (response.headers('Content-Type') === 'application/vnd.error+json') {
        response.error = new HalError(response.data);
      } else {
        response.error = {
          message: response.statusText,
          status: response.status
        };
      }
      return $q.reject(response);
    }
  };
})

Als introduce mechanism for client of the library to configure their own error handlers by media type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions