{"id":24663914,"url":"https://github.com/fatmatto/throwable-http-errors","last_synced_at":"2025-09-12T17:33:42.311Z","repository":{"id":30176103,"uuid":"123403378","full_name":"fatmatto/throwable-http-errors","owner":"fatmatto","description":"Throwable HTTP errors for node apis","archived":false,"fork":false,"pushed_at":"2023-07-19T07:10:27.000Z","size":586,"stargazers_count":3,"open_issues_count":2,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-04-08T16:45:43.684Z","etag":null,"topics":["errors","es6","http","nodejs"],"latest_commit_sha":null,"homepage":null,"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/fatmatto.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"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}},"created_at":"2018-03-01T08:12:07.000Z","updated_at":"2024-06-17T08:37:23.554Z","dependencies_parsed_at":"2024-06-17T08:54:26.524Z","dependency_job_id":null,"html_url":"https://github.com/fatmatto/throwable-http-errors","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fatmatto%2Fthrowable-http-errors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fatmatto%2Fthrowable-http-errors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fatmatto%2Fthrowable-http-errors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fatmatto%2Fthrowable-http-errors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fatmatto","download_url":"https://codeload.github.com/fatmatto/throwable-http-errors/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235665642,"owners_count":19026236,"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":["errors","es6","http","nodejs"],"created_at":"2025-01-26T05:17:24.316Z","updated_at":"2025-01-26T05:17:25.026Z","avatar_url":"https://github.com/fatmatto.png","language":"JavaScript","readme":"[![Build Status](https://travis-ci.org/fatmatto/throwable-http-errors.svg?branch=master)](https://travis-ci.org/fatmatto/throwable-http-errors)\n\n# Throwable HTTP errors\n\nThrowable HTTP errors for node APIs.\n\n## Installation\n\n```bash\nnpm i throwable-http-errors\n```\n\n## Usage\n\n```javascript\nconst Errors = require('throwable-http-errors')\n\n// for example, using express.js\nrouter.post('/', wrap(async (req, res, next) =\u003e {\n  try {\n    if (!validatePet(req.body)) {\n      throw new Errors.BadRequest()\n    }\n\n    const pet = await PetsController.create(req.body)\n    res.send({ status: true, data: pet })\n  } catch (e) {\n    return next(e)\n  }\n}))\n```\n\n## Reason\n\nBefore async/await, I was used to send errors to the main error catching middleware just by running\n\n```javascript\nreturn next(new Errors.BadRequest())\n```\n\nNow, with async/await we can leverage try/catch blocks to handle errors. While I'm not quite happy with having try/catch blocks in every route, having **await** for promises improves code readablity (and quality in my opinion) a lot.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffatmatto%2Fthrowable-http-errors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffatmatto%2Fthrowable-http-errors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffatmatto%2Fthrowable-http-errors/lists"}