{"id":17891352,"url":"https://github.com/alvarolorentedev/express-exception-handler","last_synced_at":"2025-03-22T20:33:09.564Z","repository":{"id":23577461,"uuid":"99367301","full_name":"alvarolorentedev/express-exception-handler","owner":"alvarolorentedev","description":"express-exception-handler","archived":false,"fork":false,"pushed_at":"2024-10-22T00:13:52.000Z","size":1444,"stargazers_count":8,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-22T21:43:36.726Z","etag":null,"topics":["exception-handler","exception-handling","exceptions","express","express-middleware","expressjs","hacktoberfest"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alvarolorentedev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["kanekotic"],"custom":["https://www.paypal.me/kanekotic/"]}},"created_at":"2017-08-04T17:52:16.000Z","updated_at":"2024-10-22T00:13:56.000Z","dependencies_parsed_at":"2023-09-26T04:54:28.096Z","dependency_job_id":"d4184bc9-dc02-4b3d-84ea-bacf5512674f","html_url":"https://github.com/alvarolorentedev/express-exception-handler","commit_stats":{"total_commits":456,"total_committers":8,"mean_commits":57.0,"dds":0.3092105263157895,"last_synced_commit":"4cca054413e39c560192a5a71bdb75fab4185abc"},"previous_names":["alvarolorentedev/express-exception-handler","kanekotic/express-exception-handler"],"tags_count":255,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alvarolorentedev%2Fexpress-exception-handler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alvarolorentedev%2Fexpress-exception-handler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alvarolorentedev%2Fexpress-exception-handler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alvarolorentedev%2Fexpress-exception-handler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alvarolorentedev","download_url":"https://codeload.github.com/alvarolorentedev/express-exception-handler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221839142,"owners_count":16889590,"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":["exception-handler","exception-handling","exceptions","express","express-middleware","expressjs","hacktoberfest"],"created_at":"2024-10-28T14:16:44.196Z","updated_at":"2024-10-28T14:16:44.858Z","avatar_url":"https://github.com/alvarolorentedev.png","language":"JavaScript","readme":"# ![logomakr_6nl700](https://user-images.githubusercontent.com/3071208/28988724-97dc463a-7971-11e7-9cec-ffc06bcc9205.png)\n[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors)\n[![Build Status](https://travis-ci.org/kanekotic/express-exception-handler.svg?branch=master)](https://travis-ci.org/kanekotic/express-exception-handler)\n[![codecov](https://codecov.io/gh/kanekotic/express-exception-handler/branch/master/graph/badge.svg)](https://codecov.io/gh/kanekotic/express-exception-handler)\n[![npm](https://img.shields.io/npm/dt/express-exception-handler.svg)](https://github.com/kanekotic/express-exception-handler)\n[![GitHub license](https://img.shields.io/github/license/kanekotic/express-exception-handler.svg)](https://github.com/kanekotic/express-exception-handler/blob/master/LICENSE)\n[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://GitHub.com/kanekotic/express-exception-handler/graphs/commit-activity)\n\n## Motivation\nThis package was created to add a general way to handle exception for express application with the expectation to make it simpler to handle all possible requests.\n\n## Installation\nadd it to your project with `npm install express-exception-handler` or `yarn add express-exception-handler`\n\n\n## Use\nthere are 2 different ways to integrate the main functionality of this package, either by adding the handle that gets injected to the router framework\n\n```js\nvar exceptionHandler = require('express-exception-handler')\nexceptionHandler.handle()\nconst app = require('express')()\n```\n\nor by wraping manually the routes\n\n```js\nvar wrap = require('express-exception-handler').wrap\nrouter.post('/', wrap(async (req, res) =\u003e {\n    ...\n}))\n```\n\nit also integrates an extended class from Error that contains a `message` and a `status` that can be used to pass diferent information to the error handle\n\n```js\nvar httpError = require('express-exception-handler').exception\nrouter.post('/', async (req, res) =\u003e {\n    throw new HttpError('Great Message', 400, \"{Response: awesome}\")\n}))\n```\n\nlast but not least it also contains a middleware that can be added directly to express that handles the previous named errors.\n\n```js\nvar middleware = require('express-exception-handler').middleware\nconst app = require('express')()\napp.use(middleware)\n```\n\n### Options\n\nThe `handle` and the `wrap` function allow configuration parameters to be passed. The default is:\n\n```js\n{\n  nextOnce: true,\n  defaultJsonResponse: false,\n}\n```\n\n* nextOnce: makes sure next can only be called once\n* defaultJsonResponse: runs `res.json` by default when the internally returned value is an object. \n\n### Logo\n\nArrows graphic by \u003ca href=\"http://www.flaticon.com/authors/madebyoliver\"\u003emadebyoliver\u003c/a\u003e from \u003ca href=\"http://www.flaticon.com/\"\u003eFlaticon\u003c/a\u003e is licensed under \u003ca href=\"http://creativecommons.org/licenses/by/3.0/\" title=\"Creative Commons BY 3.0\"\u003eCC BY 3.0\u003c/a\u003e. Check out the new logo that I created on \u003ca href=\"http://logomakr.com\" title=\"Logo Maker\"\u003eLogoMaker.com\u003c/a\u003e https://logomakr.com/6nL7006nL700\n## Contributors\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"http://www.bradreed.co.uk\"\u003e\u003cimg src=\"https://avatars2.githubusercontent.com/u/627654?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eBrad Reed\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/kanekotic/express-exception-handler/commits?author=noisyscanner\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/ozomer\"\u003e\u003cimg src=\"https://avatars1.githubusercontent.com/u/1161260?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eOren Zomer\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/kanekotic/express-exception-handler/commits?author=ozomer\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/Nogias9x\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/11822492?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eTu Nguyen\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"#ideas-Nogias9x\" title=\"Ideas, Planning, \u0026 Feedback\"\u003e🤔\u003c/a\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n\u003c!-- markdownlint-restore --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!\n","funding_links":["https://github.com/sponsors/kanekotic","https://www.paypal.me/kanekotic/"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falvarolorentedev%2Fexpress-exception-handler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falvarolorentedev%2Fexpress-exception-handler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falvarolorentedev%2Fexpress-exception-handler/lists"}