Skip to content

Provide a JSON view of the error info page #227

@rowanmanning

Description

@rowanmanning

Currently the error info page is only viewable as HTML. We should consider adding a JSON-based view.

What problem does this feature solve?

For JSON-based APIs, an HTML error page doesn't make a lot of sense, especially when most local development is done using curl or Postman. In these cases it's actually unhelpful to have an HTML-based error page.

Ideal solution

We allow for apps to configure the error info page to output the data as JSON instead of HTML. Something like this:

const renderErrorInfoPage = require('@dotcom-reliability-kit/middleware-render-error-info');

app.use(renderErrorInfoPage({
    renderer: 'json' // defaults to 'html'
}));

Alternatives

  • We could do nothing. Maybe this isn't actually a use-case we need to consider? If an app is JSON-based then it's likely (it should be) already handling errors and responding with a JSON representation.

  • Instead of complicating the error debug page, maybe we provide a separate production-ready JSON-based error handler which. This would require us deciding on a single standard for JSON-based errors which works for all our apps.

See also

CPREL-322

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestpackage: middleware-render-error-infoRelates to the middleware-render-error-info packagerequestedUsed to indicate that a team outside of the maintainers of this repo has requested this work

    Type

    No type

    Projects

    Status

    📥 Inbox

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions