{"_id":"@20i/exceptions","_rev":"52-40e042aab7f68d9cf3718ca7b5a08d2a","name":"@20i/exceptions","dist-tags":{"latest":"1.0.24"},"versions":{"1.0.24":{"name":"@20i/exceptions","version":"1.0.24","author":{"name":"wolf"},"license":"ISC","_id":"@20i/exceptions@1.0.24","maintainers":[{"name":"and0r","email":"akoch@twentyideas.com"},{"name":"dan20i","email":"dan@twentyideas.com"},{"name":"mesqueeb","email":"mesqueeb@gmail.com"},{"name":"mckelveygreg","email":"mckelveygreg@gmail.com"},{"name":"cavemanagz","email":"alex@twentyideas.com"},{"name":"laurelbenson","email":"laurel@twentyideas.com"},{"name":"vvolfster","email":"shahan@zabaat.com"},{"name":"keith20i","email":"keith@twentyideas.com"},{"name":"zabaat","email":"brett@zabaat.com"}],"dist":{"shasum":"71e06a5435ad1bb590ef1462b5fe45a8938e9248","tarball":"https://registry.npmjs.org/@20i/exceptions/-/exceptions-1.0.24.tgz","fileCount":9,"integrity":"sha512-pMDeE3KgHrz5d1dBg/stNPRuHT97oy/JqZVezUKmr/TwUSIh4JcwNl3pLUJr9xHLHJBc1N9RR33mYCfUhQStbA==","signatures":[{"sig":"MEYCIQCQ6/k48NHYvorOBG+wneF6E6Z5Q7g/Ank6jdCSvOLJ1wIhANPz/e3qPqBo0bAjj/kJgq1w65MHeeX1THglbqjRiROo","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":8942,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeKPBQCRA9TVsSAnZWagAAEeQP/2jdhDShsCeU4FHenvw+\nPROJw4pU0vZYG7w5znTTsDprmxoOCA8D2Gp0IbP2yhUvZs+uXGaqElN9QF/F\npm7jhdIhZQRCR32ZFic57sE9YYvVLee/ZqFZ1ghjuAcbDFPRrA8RJWrnFzLl\nHEBrHFdf8//EpyL2B6SNUJL4vV1h61sstggPuG82jXvDJvBTn2GL76iqoG2t\nJI0m9oPJUEb1uAix7O5omdHwufcVYy8lFYZs679Fe7hBwsUMwJb8D6AVRuN/\n88h6BunDHNRSn34O1eMTuqTKJXh+O7niE5LyvjpOmHgafw0TEiV+D/VZH9rU\nmsx+SQMBA+/O0W6uS4fh2eaHdKOsJ5LQR39tHQhx5AHDuDNDHelidL5mbv1/\nTpp1n76aqvvT/qkiiHLNhVuOFKn4vjSmnGC5pYSfzmvbFuKMaUrs8O1KI5lP\nkrQuH4M/Wq6KCrWptCdaR9t4Z1FaYpnvEGUIxHqonM1dtCPDUYOazH11DEim\nDnQE/tFwrZHzGYrJtGRbLhNeGJXaAZ9kvMK7jbMy49LgfQw+hkS0QfzLtfy0\nrhpuK7OdW54OHUDT8rq5Bls/B2aZUNeGy2YGs2gOMtid8li8BhocZ/lDuz35\nmkha2eIFOj3gc1JJRwHwwtBGuvVF8C1VYlBp3artz5UCl75yeOgzbWPPuCqp\nQlnA\r\n=2Pw1\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","gitHead":"8ccf40ab18c6a7ebdc75499e975fe6e5ae96c718","scripts":{"dev":"npx tsc -w","build":"npx tsc"},"_npmUser":{"name":"vvolfster","email":"shahan@zabaat.com"},"_npmVersion":"lerna/3.19.0/node@v12.13.0+x64 (win32)","description":"Standard exceptions to throw","directories":{},"_nodeVersion":"12.13.0","dependencies":{"lodash":"^4.17.15"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/exceptions_1.0.24_1579741264506_0.7945669352494487","host":"s3://npm-registry-packages"}}},"time":{"created":"2020-01-23T01:01:04.506Z","modified":"2025-09-04T21:03:48.295Z","1.0.24":"2020-01-23T01:01:04.702Z"},"author":{"name":"wolf"},"license":"ISC","description":"Standard exceptions to throw","maintainers":[{"email":"wil@twentyideas.com","name":"wilblack"},{"email":"trevor.lee.dilley@gmail.com","name":"trevordilley"},{"email":"greyson@twentyideas.com","name":"wasredacted"},{"email":"james@twentyideas.com","name":"james-20i"},{"email":"npm-service@twentyideas.com","name":"20i-npm-service"},{"email":"hiddnist@gmail.com","name":"hiddn"},{"email":"keeto@twentyideas.com","name":"keeto-20i"},{"email":"gelferstone@gmail.com","name":"gelfer"},{"email":"tony@twentyideas.com","name":"tony20i"},{"email":"mook@twentyideas.com","name":"mook-20i"},{"email":"orianna@twentyideas.com","name":"orianna-20i"}],"readme":"# @20i/exceptions\r\n\r\nProvides standard exceptions to throw.\r\nWe should add to this simple library when we wish to add more.\r\n\r\nExamples:\r\n1) Throw one error:\r\n```\r\nimport * as Exception from \"@20i/exceptions\"\r\n\r\nthrow Exception.BadRequest(\"This was a bad request\")\r\n// throws { name: \"badRequest\", code: 400, message: \"This was a bad request\" }\r\n\r\nthrow Exception.Unauthorized(\"You must be logged in to do this\")\r\n// throws { name: \"unauthorized\", code: 401, message: \"You must be logged in to do this\" }\r\n\r\nthrow Exception.Forbidden(\"You do not have permission\")\r\n// throws { name: \"forbidden\", code: 403, message: \"You do not have permission\" }\r\n\r\nthrow Exception.NotFound(\"The record was not found\")\r\n// throws { name: \"notFound\", code: 404, \"The record was not found\" }\r\n\r\nthrow Exception.InternalError(\"Unexpected error\")\r\n// throws { name: \"internalError\", code: 500, \"Unexpected error\" }\r\n```\r\n\r\n2) Throw multiple errors\r\n```\r\nimport * as Exception from \"@20i/exceptions\"\r\n\r\nconst exceptions: Exception.IException = {\r\n    name: \"multipleErrors\",\r\n    code: 400,\r\n    message: [\r\n        Exception.BadRequest(\"This was a bad request\"),\r\n        Exception.Unauthorized(\"You must be logged in to do this\"),\r\n        Exception.Forbidden(\"You do not have permission\"),\r\n        Exception.NotFound(\"The record was not found\"),\r\n        Exception.InternalError(\"Unexpected error\")\r\n    ]\r\n}\r\n\r\n// reading the text from exceptions\r\nconsole.log(Exception.GetErrorMessage(exceptions))\r\n// [\r\n//    \"This was a bad request\",\r\n//    \"You must be logged in to do this\",\r\n//    \"You do not have permission\",\r\n//    \"The record was not found\",\r\n//    \"Unexpected error\"\r\n// ]\r\n```\r\n\r\n3) Axios example\r\n```\r\nimport * as Exception from \"@20i/exceptions\"\r\nimport axios, { AxiosResponse } from \"axios\"\r\n\r\nconst axiosCall = () => {\r\n    try {\r\n        const response = await axios.get(\"http://your-url-here.com\")\r\n        return response.data\r\n    } catch (e) {\r\n        const res: AxiosResponse = e.response.data\r\n        if (Exception.isException(res)) {\r\n            // print what the message(s)\r\n            Exception.GetErrorMessage(res)\r\n        }\r\n        throw res\r\n    }\r\n}\r\n\r\n\r\n```","readmeFilename":"README.md"}