{"id":15304510,"url":"https://github.com/mensaah/exceptions_js","last_synced_at":"2026-06-30T22:01:27.840Z","repository":{"id":62993619,"uuid":"152377214","full_name":"MeNsaaH/exceptions_js","owner":"MeNsaaH","description":"Create Javascript Custom Exceptions in one line","archived":false,"fork":false,"pushed_at":"2022-11-10T12:56:50.000Z","size":60,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-26T00:43:48.892Z","etag":null,"topics":["javscript"],"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/MeNsaaH.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}},"created_at":"2018-10-10T06:57:39.000Z","updated_at":"2018-10-19T03:48:32.000Z","dependencies_parsed_at":"2022-11-10T14:01:04.390Z","dependency_job_id":null,"html_url":"https://github.com/MeNsaaH/exceptions_js","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MeNsaaH/exceptions_js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MeNsaaH%2Fexceptions_js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MeNsaaH%2Fexceptions_js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MeNsaaH%2Fexceptions_js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MeNsaaH%2Fexceptions_js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MeNsaaH","download_url":"https://codeload.github.com/MeNsaaH/exceptions_js/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MeNsaaH%2Fexceptions_js/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34984784,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-30T02:00:05.919Z","response_time":92,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["javscript"],"created_at":"2024-10-01T07:56:41.092Z","updated_at":"2026-06-30T22:01:27.818Z","avatar_url":"https://github.com/MeNsaaH.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"ExtendErrors\n================\n\nDeclaring Custom Exceptions in one line. Valid for all versions of javascript. It can find very good usage in Promises.\nAll standard Error methods apply to the custom Exception created, `CustomException.stack`, `CustomException.name`, `CustomException.toString()`, `CustomException.message` and others.\n\nInstallation\n-------------\n```js\n   npm install extendErrors\n```\n\nUsage\n--------------\n```js\n    import {Exception} from 'exception'\n    \n    // const {Exception} = require('exception')\n    \n    // passing the name parameter ensures the exception displays\n    // with the name \n    // Without name parameter the Exception is instantiated as\n    // Error: some exception message\n    // With name parameter, exception is instantiated as\n    // MyCustomError: some exception message\n    const MyCustomError = new Exception(\"MyCustomError\")\n    const OtherError = new Exception\n\n    try{\n        // Some code to be tried\n        throw new MyCustomError(\"Something is not write\");\n    }catch(err) {\n        if (err instanceof MyCustomError){\n            //\n        }\n        // Or more conveniently\n        if (err.is(MyCustomError)){\n            console.log(err.toString())\n            //some code\n        }\n        if (err.is(\"MyCustomError\")) {\n            // Do Something\n        }\n\n    }\n```\n\n\nTo create exceptions with similar traits, you can use the `Exceptions` class\n\n```js\n    import {ExceptionList} from 'exception'\n\n    // const {ExceptionList} = require('exception')\n\n    const NetworkErrors = ExceptionList(['SSLError', 'ConnectionLostError', 'SMTPError'])\n\n    try{\n        // Some block of code\n        throw new NetworkErrors.SSLError(\"Unable to establish SSL Connection\")\n    }catch(err){\n        if err.is(NetworkErrors.SSLError){\n            // Do Something\n        }\n        if NetworkErrors.has(err){\n            // Do something\n        }\n    }\n\n```\n\n\nFor best practices, you should have all related exceptions in one file\n\n```js \n\n    import {OtherException, PrimaryException} from '../my_exception'\n\n    // Some Error Handling Code\n```\n\nTesting\n--------\nTo test install all dependencies and then run test\n```js\n   npm link\n   npm test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmensaah%2Fexceptions_js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmensaah%2Fexceptions_js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmensaah%2Fexceptions_js/lists"}