{"id":21038338,"url":"https://github.com/qlaffont/unify-errors","last_synced_at":"2025-05-15T15:33:33.738Z","repository":{"id":37047993,"uuid":"457802372","full_name":"qlaffont/unify-errors","owner":"qlaffont","description":"Errors Standardization in Typescript","archived":false,"fork":false,"pushed_at":"2024-11-13T17:40:51.000Z","size":1407,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-11-13T18:35:00.958Z","etag":null,"topics":["error","standardization","tsdx","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/unify-errors","language":"TypeScript","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/qlaffont.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":"2022-02-10T13:58:42.000Z","updated_at":"2024-11-13T17:40:54.000Z","dependencies_parsed_at":"2024-02-09T13:50:06.418Z","dependency_job_id":"81ba95f8-5745-49c5-a1fd-94cf48893017","html_url":"https://github.com/qlaffont/unify-errors","commit_stats":null,"previous_names":["qlaffont/unify-errors","flexper/unify-errors"],"tags_count":333,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qlaffont%2Funify-errors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qlaffont%2Funify-errors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qlaffont%2Funify-errors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qlaffont%2Funify-errors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/qlaffont","download_url":"https://codeload.github.com/qlaffont/unify-errors/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225361329,"owners_count":17462220,"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":["error","standardization","tsdx","typescript"],"created_at":"2024-11-19T13:31:22.809Z","updated_at":"2024-11-19T13:31:23.375Z","avatar_url":"https://github.com/qlaffont.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Test Coverage](https://api.codeclimate.com/v1/badges/6be8e53efc66aabc6a5e/test_coverage)](https://codeclimate.com/github/qlaffont/unify-errors/test_coverage) [![Maintainability](https://api.codeclimate.com/v1/badges/6be8e53efc66aabc6a5e/maintainability)](https://codeclimate.com/github/qlaffont/unify-errors/maintainability) ![npm](https://img.shields.io/npm/v/unify-errors) ![npm](https://img.shields.io/npm/dm/unify-errors) ![Snyk Vulnerabilities for npm package](https://img.shields.io/snyk/vulnerabilities/npm/unify-errors) ![NPM](https://img.shields.io/npm/l/unify-errors)\n\n# Unify errors\n\nA simple library to normalize typescript standard errors. Feel free to create pull request to define new errors ! Old Owner: [@flexper](https://github.com/flexper)\n\n## Usage\n\n```typescript\nimport { BadRequest } from 'unify-errors';\n\nfunction errorExample() {\n    throw new BadRequest({\n        context: \"Example context\"\n    });\n}\n```\n\n## API\n\n### BadRequest(context?)\n\nReturn: CustomError with Bad Request message.\n\n### Unauthorized(context?)\n\nReturn: CustomError with Unauthorized message.\n\n### Forbidden(context?)\n\nReturn: CustomError with Forbidden message.\n\n### NotFound(context?)\n\nReturn: CustomError with Not Found message.\n\n### RequestTimeOut(context?)\n\nReturn: CustomError with Request TimeOut message.\n\n### InternalServerError(context?)\n\nReturn: CustomError with Internal Server Error message.\n\n### NotImplemented(context?)\n\nReturn: CustomError with Not Implemented message.\n\n### TooManyRequests(context?)\n\nReturn: CustomError with Too Many Requests message.\n\n### CustomError(message, context?)\n\nThe CustomError class extends the basic typescript Error class. It is used to create all custom errors.\n\n***Params***\n\n| Field Name | Type               | Default   | Description                      |\n| ---------- | ------------------ | --------- | -------------------------------- |\n| message    | string             | mandatory | Mandatory error message property |\n| context    | CustomErrorContext | {}        | Optional record of string        |\n\n***How to use***\n\nTo create a new error type, create a new class extending **CustomError** inside the _errors_ folder.\n\n`Don't forget to export it from index.ts too`\n\n````typescript\nimport { CustomErrorContext } from '../types/CustomErrorContext';\nimport { CustomError } from './CustomError';\n\n\nexport class InternalServerError extends CustomError {\n  constructor(public context?: CustomErrorContext) {\n    super('Internal Server error', context);\n\n    // Set the prototype explicitly.\n    Object.setPrototypeOf(this, InternalServerError.prototype);\n  }\n}\n\n````\n\n## Tests\n\nTo execute jest tests (all errors, type integrity test)\n\n```\npnpm test\n```\n\n## Maintain\n\nThis package use [TSdx](https://github.com/jaredpalmer/tsdx). Please check documentation to update this package.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqlaffont%2Funify-errors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqlaffont%2Funify-errors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqlaffont%2Funify-errors/lists"}