How to use the strong-error-handler.writeErrorToResponse function in strong-error-handler

To help you get started, we’ve selected a few strong-error-handler examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github strongloop / loopback-next / packages / rest / src / actions / reject.action.ts View on Github external
reject(
    @inject(RestBindings.Http.CONTEXT) {request, response}: HandlerContext,
    error: Error,
  ) {
    const err = error as HttpError;
    if (!err.status && !err.statusCode && err.code) {
      const customStatus = codeToStatusCodeMap[err.code];
      if (customStatus) {
        err.statusCode = customStatus;
      }
    }
    const statusCode = err.statusCode || err.status || 500;
    writeErrorToResponse(err, request, response, this.errorWriterOptions);
    this.logError(err, statusCode, request);
  }

strong-error-handler

Error handler for use in development and production environments.

MIT
Latest version published 20 days ago

Package Health Score

75 / 100
Full package analysis

Popular strong-error-handler functions

Similar packages