How to use the http-errors.ServiceUnavailable function in http-errors

To help you get started, we’ve selected a few http-errors 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 MoonMail / MoonMail / campaigns-microservice-new / common / middlewares / apiRequestRoutine.ts View on Github external
export function buildErrorResponse(error: Error): Response {
  let httpError: HttpError;
  if (error instanceof HttpError) {
    httpError = error;
  } else {
    httpError = new ServiceUnavailable('Upstream service is unavailable')
  }
  return {
    statusCode: httpError.statusCode,
    headers: DEFAULT_HEADERS,
    body: JSON.stringify({
      status: httpError.name,
      statusCode: httpError.statusCode,
      message: httpError.message
    })
  };
};
github fastify / fastify-sensible / lib / httpErrors.js View on Github external
serviceUnavailable: function serviceUnavailable (message) {
    return new createError.ServiceUnavailable(message)
  },