{"id":18391452,"url":"https://github.com/figadore/express-error-handler","last_synced_at":"2025-04-12T09:39:37.970Z","repository":{"id":57358465,"uuid":"47850276","full_name":"figadore/express-error-handler","owner":"figadore","description":"error handling functionality for express/nodejs","archived":false,"fork":false,"pushed_at":"2016-10-10T22:55:27.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-01T15:09:46.876Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/figadore.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-11T20:49:19.000Z","updated_at":"2016-01-25T19:56:49.000Z","dependencies_parsed_at":"2022-09-06T22:21:36.523Z","dependency_job_id":null,"html_url":"https://github.com/figadore/express-error-handler","commit_stats":null,"previous_names":["shinymayhem/express-error-handler"],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/figadore%2Fexpress-error-handler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/figadore%2Fexpress-error-handler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/figadore%2Fexpress-error-handler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/figadore%2Fexpress-error-handler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/figadore","download_url":"https://codeload.github.com/figadore/express-error-handler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247639460,"owners_count":20971542,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T01:51:54.667Z","updated_at":"2025-04-12T09:39:37.945Z","avatar_url":"https://github.com/figadore.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Express Error Handler\n\nFormats errors for the api-problem+json media-type\n\nError details (e.g. name, message, stack) will be included if the `showDetails` option is set. If the error already has a `detail` property, that is included as well, either as `description` if it is a string, or as the included properties if it is an object.\n\nIf `err.status`, `err.statusCode` or `err.output.statusCode` is set, that will set the HTTP status for the error response. It will also display the error's `message` property.\n\n## Usage\nInclude  the module\n\n`errorHandler = require('shiny-express-errors');`\n\n[handleErrors]{#handleErrors}\n[handleUncaughtErrors]{#handleUncaughtErrors}\n[sendError]{#sendError}\n[serializer]{#serializer}\n[getStatusCode]{#getStatusCode}\n[getRootError]{#getRootError}\n\n---\n\u003ca name=\"handleErrors\"\u003e\u003c/a\u003e\nAdd middleware for error handling\n\n`app.use(errorHandler.handleErrors(options));`\n\n### options\n* `showDetails`: boolean|function(err, req). whether to include error details (like stack) in response. Defaults to return true if statusCode is known and less than 500. Suggest changing it to show for all but 500+ in production\n\n* `showStack`: boolean|function(err, req). whether to include stack trace in response. Defaults to false. Suggest changing it to show for all but production\n\n* `errorCallback`: function(err, req, responseSent). callback to run before sending error response (e.g. custom logging or whatever). responseSent is a boolean, `true` if response headers have already been sent, i.e. next(err) will not be called, so error is not indicated is response. Defaults to doing nothing\n\n* `describedBy`: string|function(req). when string, value will be used in the `describedBy` field. when function, function will be run to generate field (with `req` as an argument). Defaults to `\u003chost\u003e/errors/error.html`\n\n---\n\u003ca name=\"handleUncaughtErrors\"\u003e\u003c/a\u003e\n\nAdd middleware for uncaught errors (uses domains). Attempts to send error response if response not already sent. Then it closes any open connections before shutting down the server. Server should be shut down after an uncaught exception: it always indicates a programmer error that should be fixed immediately.\n\n`app.use(errorHandler.handleUncaughtErrors(options));`\n\n### options\n* `callback`: function(err, req). callback to run before closing\n\n---\n\u003ca name=\"sendError\"\u003e\u003c/a\u003e\nSend an error response to the client. Sends using api-problem media type.\n\n`errorHandler.sendError(req, res, status, title, detail)`\n\n---\n\u003ca name=\"serializer\"\u003e\u003c/a\u003e\nBunyan serializer. Includes recursive verror walking\n`serializer = require('shiny-express-errors').serializer;`\n\n\n---\n\u003ca name=\"getStatusCode\"\u003e\u003c/a\u003e\nInspect Error object to try to determine appropriate http status code\n\n\n```\nvar code = serializer.statusCode(err);\n```\n\n---\n\u003ca name=\"getRootError\"\u003e\u003c/a\u003e\nGet root error. Recurses verrors to get original error object\n\n```\nvar e = serializer.getRootError(err);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffigadore%2Fexpress-error-handler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffigadore%2Fexpress-error-handler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffigadore%2Fexpress-error-handler/lists"}