{"id":22747224,"url":"https://github.com/one-com/node-httperrors","last_synced_at":"2025-10-26T20:50:35.990Z","repository":{"id":2548059,"uuid":"3526095","full_name":"One-com/node-httperrors","owner":"One-com","description":"Handy JavaScript Error classes representing the standard HTTP errors. Easily extensible and subclassable.","archived":false,"fork":false,"pushed_at":"2023-04-14T19:18:52.000Z","size":148,"stargazers_count":31,"open_issues_count":7,"forks_count":4,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-04-14T09:07:39.472Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/One-com.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2012-02-23T14:35:03.000Z","updated_at":"2024-01-22T06:54:20.000Z","dependencies_parsed_at":"2023-07-08T09:48:58.501Z","dependency_job_id":null,"html_url":"https://github.com/One-com/node-httperrors","commit_stats":{"total_commits":66,"total_committers":7,"mean_commits":9.428571428571429,"dds":"0.18181818181818177","last_synced_commit":"a797865c0e90faf5ac3e6fef927083790b3d2d71"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/One-com%2Fnode-httperrors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/One-com%2Fnode-httperrors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/One-com%2Fnode-httperrors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/One-com%2Fnode-httperrors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/One-com","download_url":"https://codeload.github.com/One-com/node-httperrors/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248872234,"owners_count":21175376,"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-12-11T03:13:48.323Z","updated_at":"2025-10-26T20:50:30.935Z","avatar_url":"https://github.com/One-com.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"node-httperrors\n===============\n\nExposes HTTP 4xx and 5xx status codes as JavaScript Error objects. The error classes are created using the \u003ca href=\"https://github.com/One-com/node-createerror\"\u003ecreateError module\u003c/a\u003e.\n\nThe original use case for `httpErrors` is to use a custom \u003ca href=\"https://github.com/visionmedia/express\"\u003eexpress\u003c/a\u003e error handler that uses the `statusCode` property of the error instance as the status code for the response, and optionally logs further info from the error.\n\n\nInstallation\n------------\n\nMake sure you have node.js and npm installed, then run:\n\n    npm install httperrors\n\nUsage\n-----\n\n    var httpErrors = require('httperrors');\n\n    // Instatiate by status code:\n    var myError = httpErrors(412);\n\n    // Instantiate by name (UpperCamelCase):\n    var err = new httpErrors.NotFound('The thing you were looking for was not found');\n\n    console.warn(err.toString()); // NotFound [404]: The thing you were looking for was not found\n\n    if (identityCrisis) {\n        throw new httpErrors.ImATeapot('Dude...');\n    }\n\nThe CamelCased error name is exposed as a true property on the\ninstances, so your error handling code becomes quite readable (and you\ncan avoid using instanceof):\n\n    if (err.NotFound) {\n        // ...\n    } else if (err.BadGateway) {\n        // ...\n    }\n\nYou can also create an error by status code (useful when proxying):\n\n    function fetchSomething(cb) {\n        var request = require('request');\n        request('http://example.com/thething', function (err, response) {\n            if (err) {\n                return cb(new (httpErrors[response.statusCode] || httpErrors.BadGateway)());\n            }\n            // ...\n        });\n    }\n\nLicense\n-------\n\n3-clause BSD license -- see the `LICENSE` file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fone-com%2Fnode-httperrors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fone-com%2Fnode-httperrors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fone-com%2Fnode-httperrors/lists"}