{"id":23138493,"url":"https://github.com/deployable/deployable-errors","last_synced_at":"2025-04-04T09:44:24.364Z","repository":{"id":149113368,"uuid":"75610463","full_name":"deployable/deployable-errors","owner":"deployable","description":"Javascript extended Error classes","archived":false,"fork":false,"pushed_at":"2017-03-14T10:48:24.000Z","size":45,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-09T20:28:15.758Z","etag":null,"topics":["deployable","error-handling","errors","extend-errors","nodejs","npm-module"],"latest_commit_sha":null,"homepage":null,"language":"CoffeeScript","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/deployable.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-12-05T09:41:35.000Z","updated_at":"2017-01-12T02:49:48.000Z","dependencies_parsed_at":"2023-04-26T01:01:54.148Z","dependency_job_id":null,"html_url":"https://github.com/deployable/deployable-errors","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deployable%2Fdeployable-errors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deployable%2Fdeployable-errors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deployable%2Fdeployable-errors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deployable%2Fdeployable-errors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deployable","download_url":"https://codeload.github.com/deployable/deployable-errors/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247157133,"owners_count":20893210,"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":["deployable","error-handling","errors","extend-errors","nodejs","npm-module"],"created_at":"2024-12-17T13:10:59.639Z","updated_at":"2025-04-04T09:44:24.318Z","avatar_url":"https://github.com/deployable.png","language":"CoffeeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @deployable/errors\n\nA set of ES2015 custom Error classes including a base class `ExtendedError` to create any new Error classes from. \n\nRequires Node 6+\n\n## Usage\n\n```\nnpm install --save @deployable/errors`   \nyarn add @deployable/errors\n```\n\nThen require\n\n```javascript \nconst {ValidationError, KeyError, HttpError, ExtendedError, FsError, RethrownError } = require('@deployable/errors')\n```\n\n## `ExtendedError`\n\nBase class used to extend errors\n\n\n``` javascript\nconst {ExtendedError} = require('@deployable/errors')\n\nclass MyError extends ExtendedError {}\n\nlet err = new MyError('Here\\'s a new error!')\n```\n\n\n#### `.simple`\n\nPlace to store a human readable error message.\n\n``` javascript\nlet err = new MyError('foo missing bar variable.', { simple: \"There was problem with foo\" })\n   \nconsole.log(err.simple)\n```\n\n## `ValidationError`\n\nAn error to throw when something simple goes wrong to be handled with output to the user. \n\n``` javascript\nconst {ValidationError} = require('@deployable/errors')\n\nlet err = new ValidationError('Store should not be a number', { field: 'store', value: 9 })\n```\n\nThe error holds the `.value` and `.field` properties for later inspection.\n\n#### `.field`\n\nValidation field\n\n#### `.value`\n\nValidation value\n\n\n## `HttpError`\n\nHttpError includes a helper function that will lookup a HTTP spec table of errors.\nIt can include a standard error message if none is provided.\n\n``` javascript\nconst {HttpError} = require('@deployable/errors')\n\nlet err = HttpError.create(403,'You are not allowed to access /admin')\n```\n\nA HttpError stores the `.status` for later use, like in an Express error route.\n\n#### `.status`\n\nStores the HTTP Status code.\n \n## `KeyError`\n\nSomething generic to throw when a property is missing (Rubyish)\n\n``` javascript\nconst {KeyError} = require('@deployable/errors')\n  \nlet store = { one: 1, two: 2 }\nley key = 'three'\nlet number = store[three]\nif (!number) throw new KeyError('Number not found', { key: key })\nreturn number\n```\n\n#### `.key`\n\nThe key that failed\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeployable%2Fdeployable-errors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeployable%2Fdeployable-errors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeployable%2Fdeployable-errors/lists"}