{"_id":"@beautinique/backend-classes","_rev":"8-ea4159022fa2b8d2bafc610c04c08364","name":"@beautinique/backend-classes","dist-tags":{"latest":"1.0.7"},"versions":{"1.0.0":{"name":"@beautinique/backend-classes","version":"1.0.0","keywords":["backend","classes","errors","success","beautinique"],"author":{"name":"Nageshwar Pawar"},"license":"MIT","_id":"@beautinique/backend-classes@1.0.0","maintainers":[{"name":"beautinique","email":"beautinique.bq@gmail.com"}],"homepage":"https://github.com/Nageshwar1997/BQ-Packages/tree/main/packages/backend/classes#readme","bugs":{"url":"https://github.com/Nageshwar1997/BQ-Packages/issues"},"dist":{"shasum":"b1b9400ce62b2fcd62b26a8cddce80b7815c9a77","tarball":"https://registry.npmjs.org/@beautinique/backend-classes/-/backend-classes-1.0.0.tgz","fileCount":8,"integrity":"sha512-nxUfB6Vuz19TtdriGjTHHhm1jRnhiaGn901OO2NCZujFYb26z4ok2pWS1z1//piYFFiaiBzK4RmPR7CLVbieYA==","signatures":[{"sig":"MEUCIDj/XnY8v0rvsmqRbMz9qb77xz+U6/3AFMfuu0TNJ1vgAiEAiSe6J89P0WeFFRlc3pi86zhPD1tENZSs953c/Jtlr3E=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":118603},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=24"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","default":"./dist/index.js","require":"./dist/index.cjs"},"./package.json":"./package.json"},"gitHead":"091dd3be63f46076caffac02eea7196fcb459922","scripts":{"dev":"tsup --watch","lint":"eslint .","build":"tsup","typecheck":"tsc --noEmit"},"_npmUser":{"name":"beautinique","email":"beautinique.bq@gmail.com"},"repository":{"url":"git+https://github.com/Nageshwar1997/BQ-Packages.git","type":"git","directory":"packages/backend/classes"},"_npmVersion":"11.8.0","description":"Backend classes for Beautinique project.","directories":{},"sideEffects":false,"_nodeVersion":"24.13.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^6.0.3"},"_npmOperationalInternal":{"tmp":"tmp/backend-classes_1.0.0_1783080643855_0.61898768625593","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@beautinique/backend-classes","version":"1.0.1","keywords":["backend","classes","errors","success","beautinique"],"author":{"name":"Nageshwar Pawar"},"license":"MIT","_id":"@beautinique/backend-classes@1.0.1","maintainers":[{"name":"beautinique","email":"beautinique.bq@gmail.com"}],"homepage":"https://github.com/Nageshwar1997/BQ-Packages/tree/main/packages/backend/classes#readme","bugs":{"url":"https://github.com/Nageshwar1997/BQ-Packages/issues"},"dist":{"shasum":"5246a2997e7543a4f66fdde9975c01460e235d51","tarball":"https://registry.npmjs.org/@beautinique/backend-classes/-/backend-classes-1.0.1.tgz","fileCount":8,"integrity":"sha512-r0wErE4sB1GM2Fi8XytlhgaYlmrLEfvDxMJGws93XctwiR1ZqRUWmOt1F+CaPfSWYEQa8X5HKAahEZg6ot7p2w==","signatures":[{"sig":"MEUCIBbMxVrFvyS8DLYIMbViZmZD0/EMoCgykQu+zyQQPidxAiEAy/ACE2it9bqZssL8fVdj9PD5Tb2rPYa3cZY73q1vVGI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":118746},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=24"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","default":"./dist/index.js","require":"./dist/index.cjs"},"./package.json":"./package.json"},"gitHead":"aa57452081ac4d4e37bc9fdfee34604ebf3f5d9e","scripts":{"dev":"tsup --watch","lint":"eslint .","build":"tsup","typecheck":"tsc --noEmit"},"_npmUser":{"name":"beautinique","email":"beautinique.bq@gmail.com"},"repository":{"url":"git+https://github.com/Nageshwar1997/BQ-Packages.git","type":"git","directory":"packages/backend/classes"},"_npmVersion":"11.8.0","description":"Backend classes for Beautinique project.","directories":{},"sideEffects":false,"_nodeVersion":"24.13.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^6.0.3","@beautinique/shared-types":"^1.0.5"},"_npmOperationalInternal":{"tmp":"tmp/backend-classes_1.0.1_1783250656271_0.7692588239798588","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@beautinique/backend-classes","version":"1.0.2","keywords":["backend","classes","errors","success","beautinique"],"author":{"name":"Nageshwar Pawar"},"license":"MIT","_id":"@beautinique/backend-classes@1.0.2","maintainers":[{"name":"beautinique","email":"beautinique.bq@gmail.com"}],"homepage":"https://github.com/Nageshwar1997/BQ-Packages/tree/main/packages/backend/classes#readme","bugs":{"url":"https://github.com/Nageshwar1997/BQ-Packages/issues"},"dist":{"shasum":"a13d6c81311cec3bf0186b3a73ad32cb681bff5a","tarball":"https://registry.npmjs.org/@beautinique/backend-classes/-/backend-classes-1.0.2.tgz","fileCount":126,"integrity":"sha512-rqCS1Pw8JJr+P9OcwsjE/5rSHfUQculYbGeWD5nuVkfz/hd9PqqZuHzrBdAtbWY5iCLviH72X9POkYSEgmMNCQ==","signatures":[{"sig":"MEUCIGnf/3XrmcJxjMUGDK/Es9j2IxEhO0cC7bKfbAU7EWk9AiEAqw7ALVeJAQKiyjCsOupPgwHvDeeQbbCeDJa1jcrzBow=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":152184},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=24"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","default":"./dist/index.js","require":"./dist/index.cjs"},"./package.json":"./package.json"},"gitHead":"309063216b8eafe33d6f8bb794e6ee6b96aedb9d","scripts":{"dev":"tsup --watch","lint":"eslint .","build":"tsup","postbuild":"node ../../../scripts/build-types/index.mjs","typecheck":"tsc --noEmit"},"_npmUser":{"name":"beautinique","email":"beautinique.bq@gmail.com"},"repository":{"url":"git+https://github.com/Nageshwar1997/BQ-Packages.git","type":"git","directory":"packages/backend/classes"},"_npmVersion":"11.8.0","description":"Backend classes for Beautinique project.","directories":{},"sideEffects":false,"_nodeVersion":"24.13.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^6.0.3","@beautinique/shared-types":"^1.0.5"},"_npmOperationalInternal":{"tmp":"tmp/backend-classes_1.0.2_1784656503585_0.39701695053628194","host":"s3://npm-registry-packages-npm-production"}},"1.0.3":{"name":"@beautinique/backend-classes","version":"1.0.3","keywords":["backend","classes","errors","success","beautinique"],"author":{"name":"Nageshwar Pawar"},"license":"MIT","_id":"@beautinique/backend-classes@1.0.3","maintainers":[{"name":"beautinique","email":"beautinique.bq@gmail.com"}],"homepage":"https://github.com/Nageshwar1997/BQ-Packages/tree/main/packages/backend/classes#readme","bugs":{"url":"https://github.com/Nageshwar1997/BQ-Packages/issues"},"dist":{"shasum":"9cee12a38ef8b941f9c58110cb4e006b0e0906c8","tarball":"https://registry.npmjs.org/@beautinique/backend-classes/-/backend-classes-1.0.3.tgz","fileCount":126,"integrity":"sha512-MC60dBxafH+CHnkXwMxxFPwNSPu/tevYl/DZxfb7qnzoI5BuIiNrB8D+X3io1cvb1B29aEcrd5zkSZEF7rO5+A==","signatures":[{"sig":"MEYCIQCdmRwN3bh69oJinmiKOgshwFhR7BHExWA8DX4X74l/4gIhALmEg5QjcyX7IUQuNcvX56GHb5wtfqgiQzJARa8ow8zU","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":152185},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=24"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","default":"./dist/index.js","require":"./dist/index.cjs"},"./package.json":"./package.json"},"gitHead":"111d1c59732fda60523fe280e274a3b07ecdcd48","scripts":{"dev":"tsup --watch","lint":"eslint .","build":"tsup","postbuild":"node ../../../scripts/build-types/index.mjs","typecheck":"tsc --noEmit"},"_npmUser":{"name":"beautinique","email":"beautinique.bq@gmail.com"},"repository":{"url":"git+https://github.com/Nageshwar1997/BQ-Packages.git","type":"git","directory":"packages/backend/classes"},"_npmVersion":"11.8.0","description":"Backend classes for Beautinique project.","directories":{},"sideEffects":false,"_nodeVersion":"24.13.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^6.0.3","@beautinique/shared-types":"^1.0.11"},"_npmOperationalInternal":{"tmp":"tmp/backend-classes_1.0.3_1784657628080_0.9642243500363206","host":"s3://npm-registry-packages-npm-production"}},"1.0.4":{"name":"@beautinique/backend-classes","version":"1.0.4","keywords":["backend","classes","errors","success","beautinique"],"author":{"name":"Nageshwar Pawar"},"license":"MIT","_id":"@beautinique/backend-classes@1.0.4","maintainers":[{"name":"beautinique","email":"beautinique.bq@gmail.com"}],"homepage":"https://github.com/Nageshwar1997/BQ-Packages/tree/main/packages/backend/classes#readme","bugs":{"url":"https://github.com/Nageshwar1997/BQ-Packages/issues"},"dist":{"shasum":"c849b76dc7026cfd583ef92892f20643e714eefb","tarball":"https://registry.npmjs.org/@beautinique/backend-classes/-/backend-classes-1.0.4.tgz","fileCount":126,"integrity":"sha512-9eBipmA0lyeTq3UclL/shZ5iMMefutHvLHnaIM6sIaOtqVa7ATKKgIh0Ou1duQzocoUoVVrWd8ZmLEAQdyEeZA==","signatures":[{"sig":"MEQCIHBpUq6s4l83pbV+/jJzemQRU+RhMdtpUH6l0Ly2RtbDAiAC7fuZaQYUFMC77DH/z6siGOAOehikcpypfAIyQdDhDg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":152185},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=24"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","default":"./dist/index.js","require":"./dist/index.cjs"},"./package.json":"./package.json"},"gitHead":"e30737149d6d3916e61a909d2a30954882a1ce7e","scripts":{"dev":"tsup --watch","lint":"eslint .","build":"tsup","postbuild":"node ../../../scripts/build-types/index.mjs","typecheck":"tsc --noEmit"},"_npmUser":{"name":"beautinique","email":"beautinique.bq@gmail.com"},"repository":{"url":"git+https://github.com/Nageshwar1997/BQ-Packages.git","type":"git","directory":"packages/backend/classes"},"_npmVersion":"11.8.0","description":"Backend classes for Beautinique project.","directories":{},"sideEffects":false,"_nodeVersion":"24.13.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^6.0.3","@beautinique/shared-types":"^1.0.16"},"_npmOperationalInternal":{"tmp":"tmp/backend-classes_1.0.4_1785442748488_0.929955475870142","host":"s3://npm-registry-packages-npm-production"}},"1.0.5":{"name":"@beautinique/backend-classes","version":"1.0.5","keywords":["backend","classes","errors","success","beautinique"],"author":{"name":"Nageshwar Pawar"},"license":"MIT","_id":"@beautinique/backend-classes@1.0.5","maintainers":[{"name":"beautinique","email":"beautinique.bq@gmail.com"}],"homepage":"https://github.com/Nageshwar1997/BQ-Packages/tree/main/packages/backend/classes#readme","bugs":{"url":"https://github.com/Nageshwar1997/BQ-Packages/issues"},"dist":{"shasum":"72f1e9a853991c53188144f25270828868a9cc65","tarball":"https://registry.npmjs.org/@beautinique/backend-classes/-/backend-classes-1.0.5.tgz","fileCount":126,"integrity":"sha512-O/gFBXgaIT+E4RKQ1b7KTyJNnJ9LamJCStPbt+eGa2IJoIzGTn8WQVqzxV9u32T6vCpq4Q6JbAmyXRTCwbXijw==","signatures":[{"sig":"MEYCIQCV+zSfC+OnmQOZMiQmIlb/s8S7gK24PyPZeJm6fHtHUwIhAJUTOuxI+Jy23a+E4QipibgJCQSSCxVNJi0L8WKWpo0o","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":152767},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=24"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","default":"./dist/index.js","require":"./dist/index.cjs"},"./package.json":"./package.json"},"gitHead":"b026a3b9693c94e58dcd163010dbf39b6b79e7ea","scripts":{"dev":"tsup --watch","lint":"eslint .","build":"tsup","postbuild":"node ../../../scripts/build-types/index.mjs","typecheck":"tsc --noEmit"},"_npmUser":{"name":"beautinique","email":"beautinique.bq@gmail.com"},"repository":{"url":"git+https://github.com/Nageshwar1997/BQ-Packages.git","type":"git","directory":"packages/backend/classes"},"_npmVersion":"11.8.0","description":"Backend classes for Beautinique project.","directories":{},"sideEffects":false,"_nodeVersion":"24.13.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^6.0.3","@beautinique/shared-types":"^1.0.21"},"_npmOperationalInternal":{"tmp":"tmp/backend-classes_1.0.5_1787039108331_0.01773822492824162","host":"s3://npm-registry-packages-npm-production"}},"1.0.6":{"name":"@beautinique/backend-classes","version":"1.0.6","keywords":["backend","classes","errors","success","beautinique"],"author":{"name":"Nageshwar Pawar"},"license":"MIT","_id":"@beautinique/backend-classes@1.0.6","maintainers":[{"name":"beautinique","email":"beautinique.bq@gmail.com"}],"homepage":"https://github.com/Nageshwar1997/BQ-Packages/tree/main/packages/backend/classes#readme","bugs":{"url":"https://github.com/Nageshwar1997/BQ-Packages/issues"},"dist":{"shasum":"666c2c79b702304fd19bb22c5eca6840161d9aed","tarball":"https://registry.npmjs.org/@beautinique/backend-classes/-/backend-classes-1.0.6.tgz","fileCount":126,"integrity":"sha512-Ib97mvdwqIDAuw03dfchEy8YSKh/eK4bBRTJMNlnDuP2NY8wfmLoV2lS+7tNoCwJEYkO9MgXXk74oyPOYvfpIA==","signatures":[{"sig":"MEUCIAXFyU0XEYYwTKSkQ0LD9tkvv7IEJhW8mGgoE/bXDni5AiEAiZwSgnNDKBZ0+pZUSc8G1SVBKAYS4pxB1ibG+pzkUoM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":152767},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=24"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","default":"./dist/index.js","require":"./dist/index.cjs"},"./package.json":"./package.json"},"gitHead":"2807c53a8d389b6f0a36770b416bcc2026e40ca2","scripts":{"dev":"tsup --watch","lint":"eslint .","build":"tsup","postbuild":"node ../../../scripts/build-types/index.mjs","typecheck":"tsc --noEmit"},"_npmUser":{"name":"beautinique","email":"beautinique.bq@gmail.com"},"repository":{"url":"git+https://github.com/Nageshwar1997/BQ-Packages.git","type":"git","directory":"packages/backend/classes"},"_npmVersion":"11.10.1","description":"Backend classes for Beautinique project.","directories":{},"sideEffects":false,"_nodeVersion":"24.13.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^6.0.3","@beautinique/shared-types":"^1.0.24"},"_npmOperationalInternal":{"tmp":"tmp/backend-classes_1.0.6_1787219351747_0.5620902290728762","host":"s3://npm-registry-packages-npm-production"}},"1.0.7":{"name":"@beautinique/backend-classes","version":"1.0.7","description":"Backend classes for Beautinique project.","keywords":["backend","classes","errors","success","beautinique"],"author":{"name":"Nageshwar Pawar"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/Nageshwar1997/BQ-Packages.git","directory":"packages/backend/classes"},"bugs":{"url":"https://github.com/Nageshwar1997/BQ-Packages/issues"},"homepage":"https://github.com/Nageshwar1997/BQ-Packages/tree/main/packages/backend/classes#readme","type":"module","main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","sideEffects":false,"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs","default":"./dist/index.js"},"./package.json":"./package.json"},"scripts":{"build":"tsup","postbuild":"node ../../../scripts/build-types/index.mjs","dev":"tsup --watch","lint":"eslint .","typecheck":"tsc --noEmit"},"publishConfig":{"access":"public"},"engines":{"node":">=24"},"devDependencies":{"@beautinique/shared-types":"^1.0.26","typescript":"^6.0.3"},"gitHead":"3a5103fb9030969e849b1e69b02bbe7d1cab5fbe","_id":"@beautinique/backend-classes@1.0.7","_nodeVersion":"24.13.1","_npmVersion":"11.8.0","dist":{"integrity":"sha512-T6NlxxE0LMVF+URAS+ZHAkcfCshYx7R+0yAX4QdKYJVuZS3Xays9ajFbX0UQe3neNdAGm1ST1XyNnx5X7pxE3Q==","shasum":"03d899fc0b9ae52a5dc281e1e3fd9b08dbf92c8d","tarball":"https://registry.npmjs.org/@beautinique/backend-classes/-/backend-classes-1.0.7.tgz","fileCount":126,"unpackedSize":152767,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQC5mMaCQryK7MKSvruUf01XoowuJZzVsV9c27XKT2Z7jQIhAIzRy5SuH6cmnxxcdETRX8Rgxt5n5A8DbHMhkVXqGmS3"}]},"_npmUser":{"name":"beautinique","email":"beautinique.bq@gmail.com"},"directories":{},"maintainers":[{"name":"beautinique","email":"beautinique.bq@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/backend-classes_1.0.7_1787576701641_0.7707207917332926"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-03T12:10:43.661Z","modified":"2026-08-24T13:05:02.084Z","1.0.0":"2026-07-03T12:10:43.995Z","1.0.1":"2026-07-05T11:24:16.423Z","1.0.2":"2026-07-21T17:55:03.718Z","1.0.3":"2026-07-21T18:13:48.226Z","1.0.4":"2026-07-30T20:19:08.648Z","1.0.5":"2026-08-18T07:45:08.483Z","1.0.6":"2026-08-20T09:49:11.870Z","1.0.7":"2026-08-24T13:05:01.808Z"},"bugs":{"url":"https://github.com/Nageshwar1997/BQ-Packages/issues"},"author":{"name":"Nageshwar Pawar"},"license":"MIT","homepage":"https://github.com/Nageshwar1997/BQ-Packages/tree/main/packages/backend/classes#readme","keywords":["backend","classes","errors","success","beautinique"],"repository":{"type":"git","url":"git+https://github.com/Nageshwar1997/BQ-Packages.git","directory":"packages/backend/classes"},"description":"Backend classes for Beautinique project.","maintainers":[{"name":"beautinique","email":"beautinique.bq@gmail.com"}],"readme":"# @beautinique/backend-classes\r\n\r\nBackend classes for Beautinique project.\r\n\r\n## Installation\r\n\r\n```bash\r\nnpm install @beautinique/backend-classes\r\n```\r\n\r\n## Usage\r\n\r\n```ts\r\nimport {} from '@beautinique/backend-classes';\r\n```\r\n\r\n## Repository\r\n\r\nhttps://github.com/Nageshwar1997/BQ-Packages\r\n\r\n## Homepage\r\n\r\nhttps://github.com/Nageshwar1997/BQ-Packages\r\n\r\n## Issues\r\n\r\nhttps://github.com/Nageshwar1997/BQ-Packages/issues\r\n\r\n## Author\r\n\r\nNageshwar Pawar\r\n\r\n## License\r\n\r\nThis package is licensed under the MIT License. See the root `LICENSE` file for details.\r\n\r\n\r\n## Usage\r\n\r\n# Error Handling Guide\r\n\r\n## Overview\r\n\r\nThe application uses custom error classes to provide consistent, predictable, and type-safe error handling across the entire backend.\r\n\r\nEvery custom error extends the `AppError` base class.\r\n\r\n```ts\r\nthrow new NotFoundError('Product not found.');\r\n```\r\n\r\ninstead of\r\n\r\n```ts\r\nthrow new AppError({\r\n  message: 'Product not found.',\r\n  code: 'NOT_FOUND',\r\n});\r\n```\r\n\r\nUsing specialized error classes makes the code more readable and allows the global error handler to produce consistent API responses.\r\n\r\n## Dynamic construction - `createError` / `ERROR_CLASS_MAP`\r\n\r\nPrefer throwing a specific class directly (as above) whenever the error site knows which one it means. `createError` and `ERROR_CLASS_MAP` exist for the other case - code that only has an error **code** (a string) at hand and needs to construct the matching class dynamically, e.g. translating a third-party validation library's error code, or a generic error-response builder:\r\n\r\n```ts\r\nimport { createError, ERROR_CLASS_MAP } from '@beautinique/backend-classes';\r\n\r\nthrow createError({ message: 'Validation failed.', payload: { code: 'VALIDATION_ERROR', fieldErrors } });\r\n\r\n// ERROR_CLASS_MAP itself is available for advanced use, e.g. iterating every known code\r\nObject.keys(ERROR_CLASS_MAP); // every TErrorCode\r\n```\r\n\r\n`payload.code` defaults to `'INTERNAL_SERVER_ERROR'` when omitted.\r\n\r\n# Error Hierarchy\r\n\r\n```text\r\nAppError\r\n│\r\n├── BadRequestError\r\n├── ValidationError\r\n├── AuthenticationError\r\n├── AuthorizationError\r\n├── NotFoundError\r\n├── MethodNotAllowedError\r\n├── RequestTimeoutError\r\n├── ConflictError\r\n├── GoneError\r\n├── PreconditionFailedError\r\n├── PayloadTooLargeError\r\n├── UnsupportedMediaTypeError\r\n├── UnprocessableEntityError\r\n├── TooManyRequestsError\r\n│\r\n├── InternalServerError\r\n├── NotImplementedError\r\n├── BadGatewayError\r\n├── ServiceUnavailableError\r\n├── GatewayTimeoutError\r\n│\r\n├── DatabaseError\r\n├── ExternalServiceError\r\n├── ConfigurationError\r\n└── UnknownError\r\n```\r\n\r\n\r\n# Client Errors (4xx)\r\n\r\nThese errors indicate that the client sent an invalid request.\r\n\r\n## BadRequestError (400)\r\n\r\nUse when the request is logically invalid even though the request format is correct.\r\n\r\nTypical use cases\r\n\r\n• Invalid business rule\r\n• Invalid application state\r\n• Operation is not allowed\r\n\r\nExamples\r\n\r\n```ts\r\nthrow new BadRequestError('Order cannot be cancelled.');\r\n```\r\n\r\n```ts\r\nthrow new BadRequestError('Coupon cannot be applied.');\r\n```\r\n\r\n## ValidationError (422)\r\n\r\nUse when request validation fails.\r\n\r\nTypical use cases\r\n\r\n• Zod validation\r\n• Joi validation\r\n• Yup validation\r\n• Invalid request body\r\n• Invalid query parameters\r\n• Invalid path parameters\r\n\r\nExamples\r\n\r\n```ts\r\nthrow new ValidationError('Validation failed.', {\r\n  fieldErrors: {\r\n    email: ['Email is required'],\r\n    password: ['Password must contain at least 8 characters'],\r\n  },\r\n});\r\n```\r\n\r\n## AuthenticationError (401)\r\n\r\nUse when the user is not authenticated.\r\n\r\nTypical use cases\r\n\r\n• Missing access token\r\n• Invalid token\r\n• Expired token\r\n• Invalid refresh token\r\n\r\nExamples\r\n\r\n```ts\r\nthrow new AuthenticationError('Access token is missing.');\r\n```\r\n\r\n```ts\r\nthrow new AuthenticationError('Session expired.');\r\n```\r\n\r\n## AuthorizationError (403)\r\n\r\nUse when the user is authenticated but does not have permission.\r\n\r\nTypical use cases\r\n\r\n• Missing role\r\n• Missing permission\r\n• Resource ownership violation\r\n\r\nExamples\r\n\r\n```ts\r\nthrow new AuthorizationError(\r\n  'Only administrators can perform this action.',\r\n);\r\n```\r\n\r\n## NotFoundError (404)\r\n\r\nUse when the requested resource does not exist.\r\n\r\nTypical use cases\r\n\r\n• User not found\r\n• Product not found\r\n• Category not found\r\n• Order not found\r\n\r\nExamples\r\n\r\n```ts\r\nthrow new NotFoundError('Product not found.');\r\n```\r\n\r\n## MethodNotAllowedError (405)\r\n\r\nUse when the HTTP method is not supported.\r\n\r\nTypical use cases\r\n\r\n• PUT not allowed\r\n• DELETE not allowed\r\n• PATCH not supported\r\n\r\nExample\r\n\r\n```ts\r\nthrow new MethodNotAllowedError();\r\n```\r\n\r\n## RequestTimeoutError (408)\r\n\r\nUse when processing a request exceeds the allowed timeout.\r\n\r\nTypical use cases\r\n\r\n• Long-running operation\r\n• Request processing timeout\r\n\r\nExample\r\n\r\n```ts\r\nthrow new RequestTimeoutError();\r\n```\r\n\r\n## ConflictError (409)\r\n\r\nUse when the requested operation conflicts with the current resource state.\r\n\r\nTypical use cases\r\n\r\n• Duplicate email\r\n• Duplicate username\r\n• Duplicate SKU\r\n• Product already published\r\n\r\nExamples\r\n\r\n```ts\r\nthrow new ConflictError('Email already exists.');\r\n```\r\n\r\n## GoneError (410)\r\n\r\nUse when the resource existed previously but has been permanently removed.\r\n\r\nTypical use cases\r\n\r\n• Expired invitation\r\n• Permanently deleted resource\r\n• Expired download link\r\n\r\nExample\r\n\r\n```ts\r\nthrow new GoneError('Invitation has expired.');\r\n```\r\n\r\n## PreconditionFailedError (412)\r\n\r\nUse when request preconditions are not satisfied.\r\n\r\nTypical use cases\r\n\r\n• ETag mismatch\r\n• Version conflict\r\n• Required state not satisfied\r\n\r\nExample\r\n\r\n```ts\r\nthrow new PreconditionFailedError(\r\n  'The resource has been modified.',\r\n);\r\n```\r\n\r\n## PayloadTooLargeError (413)\r\n\r\nUse when uploaded content exceeds the configured limit.\r\n\r\nTypical use cases\r\n\r\n• Image too large\r\n• Video too large\r\n• Large request body\r\n\r\nExample\r\n\r\n```ts\r\nthrow new PayloadTooLargeError(\r\n  'Maximum image size is 2 MB.',\r\n);\r\n```\r\n\r\n## UnsupportedMediaTypeError (415)\r\n\r\nUse when uploaded media type is not supported.\r\n\r\nTypical use cases\r\n\r\n• Invalid image format\r\n• Invalid video format\r\n• Unsupported Content-Type\r\n\r\nExample\r\n\r\n```ts\r\nthrow new UnsupportedMediaTypeError(\r\n  'Only JPG and PNG files are supported.',\r\n);\r\n```\r\n\r\n## UnprocessableEntityError (422)\r\n\r\nUse when the request is syntactically correct but cannot be processed due to semantic issues.\r\n\r\nTypical use cases\r\n\r\n• Domain-specific validation\r\n• Business validation\r\n• Invalid state transition\r\n\r\nExample\r\n\r\n```ts\r\nthrow new UnprocessableEntityError(\r\n  'The order cannot be processed.',\r\n);\r\n```\r\n\r\n## TooManyRequestsError (429)\r\n\r\nUse when rate limits are exceeded.\r\n\r\nTypical use cases\r\n\r\n• OTP limit exceeded\r\n• Login attempts exceeded\r\n• API rate limiting\r\n\r\nExample\r\n\r\n```ts\r\nthrow new TooManyRequestsError(\r\n  'Too many OTP requests.',\r\n);\r\n```\r\n\r\n# Server Errors (5xx)\r\n\r\nThese errors indicate failures inside the server or dependent infrastructure.\r\n\r\n## InternalServerError (500)\r\n\r\nUse for unexpected server failures.\r\n\r\nTypical use cases\r\n\r\n• Unexpected exception\r\n• Unknown server issue\r\n\r\nExample\r\n\r\n```ts\r\nthrow new InternalServerError();\r\n```\r\n\r\n## NotImplementedError (501)\r\n\r\nUse for features that are intentionally not implemented yet.\r\n\r\nExample\r\n\r\n```ts\r\nthrow new NotImplementedError(\r\n  'This feature is not implemented yet.',\r\n);\r\n```\r\n\r\n## BadGatewayError (502)\r\n\r\nUse when another internal service returns an invalid response.\r\n\r\nTypical use cases\r\n\r\n• Invalid microservice response\r\n• Invalid upstream gateway response\r\n\r\nExample\r\n\r\n```ts\r\nthrow new BadGatewayError(\r\n  'User service returned an invalid response.',\r\n);\r\n```\r\n\r\n## ServiceUnavailableError (503)\r\n\r\nUse when a service is temporarily unavailable.\r\n\r\nTypical use cases\r\n\r\n• Maintenance mode\r\n• Redis unavailable\r\n• Dependency unavailable\r\n\r\nExample\r\n\r\n```ts\r\nthrow new ServiceUnavailableError(\r\n  'The service is temporarily unavailable.',\r\n);\r\n```\r\n\r\n## GatewayTimeoutError (504)\r\n\r\nUse when an upstream service fails to respond within the allowed timeout.\r\n\r\nTypical use cases\r\n\r\n• Payment service timeout\r\n• User service timeout\r\n\r\nExample\r\n\r\n```ts\r\nthrow new GatewayTimeoutError(\r\n  'Payment service timeout.',\r\n);\r\n```\r\n\r\n# Infrastructure Errors\r\n\r\nThese classes represent failures in application infrastructure rather than HTTP semantics.\r\n\r\n## DatabaseError\r\n\r\nUse for database-related failures.\r\n\r\nTypical use cases\r\n\r\n• MongoDB errors\r\n• PostgreSQL errors\r\n• Prisma errors\r\n• Redis database operations\r\n• Transaction failures\r\n\r\nExample\r\n\r\n```ts\r\ntry {\r\n  await User.create(data);\r\n} catch (error) {\r\n  throw new DatabaseError(\r\n    'Failed to create user.',\r\n    {\r\n      cause: error,\r\n    },\r\n  );\r\n}\r\n```\r\n\r\n## ExternalServiceError\r\n\r\nUse for failures from third-party services.\r\n\r\nTypical use cases\r\n\r\n• Cloudinary\r\n• Stripe\r\n• Razorpay\r\n• AWS S3\r\n• SMTP\r\n• Firebase\r\n\r\nExample\r\n\r\n```ts\r\ntry {\r\n  await uploadImage();\r\n} catch (error) {\r\n  throw new ExternalServiceError(\r\n    'Cloudinary upload failed.',\r\n    {\r\n      cause: error,\r\n    },\r\n  );\r\n}\r\n```\r\n\r\n## ConfigurationError\r\n\r\nUse when the application configuration is invalid.\r\n\r\nTypical use cases\r\n\r\n• Missing environment variables\r\n• Invalid configuration\r\n• Startup configuration failure\r\n\r\nExample\r\n\r\n```ts\r\nif (!process.env.JWT_SECRET) {\r\n  throw new ConfigurationError(\r\n    'JWT_SECRET environment variable is missing.',\r\n  );\r\n}\r\n```\r\n\r\n## UnknownError\r\n\r\nUse only when an unexpected error must be wrapped before rethrowing.\r\n\r\nTypical use cases\r\n\r\n• Unknown exception\r\n• Non-AppError exceptions\r\n\r\nExample\r\n\r\n```ts\r\ntry {\r\n  // ...\r\n} catch (error) {\r\n  throw new UnknownError(undefined, {\r\n    cause: error,\r\n  });\r\n}\r\n```\r\n\r\n# Best Practices\r\n\r\nAlways throw the most specific error class available.\r\n\r\n✅ Good\r\n\r\n```ts\r\nthrow new NotFoundError('Product not found.');\r\n```\r\n\r\n❌ Avoid\r\n\r\n```ts\r\nthrow new InternalServerError('Product not found.');\r\n```\r\n\r\nAlways include meaningful messages.\r\n\r\nPrefer using `ValidationError` for schema validation.\r\n\r\nUse `ConflictError` for duplicate resources.\r\n\r\nUse `AuthenticationError` for authentication failures.\r\n\r\nUse `AuthorizationError` for permission failures.\r\n\r\nWrap infrastructure failures using `DatabaseError` or `ExternalServiceError` and preserve the original error using `cause`.\r\n\r\nAvoid throwing `AppError` directly. Always use one of the specialized error classes.\r\n\r\nAllow unexpected exceptions to bubble up to the global error handler whenever possible instead of swallowing them.\r\n","readmeFilename":"README.md"}