exception-filter

所属分类:调试/Bug
开发工具:TypeScript
文件大小:0KB
下载次数:0
上传日期:2023-09-03 15:57:36
上 传 者sh-1993
说明:  异常筛选器,,
(exception-filter,,)

文件列表:
index.ts (120, 2023-10-21)
package-lock.json (28347, 2023-10-21)
package.json (2033, 2023-10-21)
src/ (0, 2023-10-21)
src/Exception.ts (4162, 2023-10-21)
src/sysInfo.ts (3158, 2023-10-21)
src/types.ts (1569, 2023-10-21)
tsconfig-cjs.json (150, 2023-10-21)
tsconfig-esm.json (141, 2023-10-21)
tsconfig.json (643, 2023-10-21)

Express.js Exception Filter/Handler ![Express.js Exception Filter/Handler](https://assets-docs.b-cdn.net/assets/madebyEnjoys.png) Overview -------- The Express.js Exception Handler is a middleware package designed to streamline error management and enhance the reliability of your Express.js applications. It simplifies the process of handling errors, customizing error messages and status codes, and maintaining clean and consistent error-handling practices. Features -------- - Robust Error Handling: Efficiently manage various error types, from validation errors to unexpected server issues. - Customization: Easily customize error messages and HTTP status codes to provide meaningful responses to clients. - Integration: Seamlessly integrate error-handling middleware into your Express.js application stack. - Best Practices: Follow industry best practices for error handling to improve the professionalism and reliability of your application. Installation ------------ You can install the Express.js Exception Filter/Handler package via npm: ```bash npm i @enjoys/exception ``` Usage ----- 1. Import the package: ES5 Syntax ```javascript const { Exception } = require('@enjoys/exception'); ``` ES6 Syntax ```javascript import { Exception } from'@enjoys/exception'; ``` To Handle Exception throughout your App, use this: 1. Add the middleware to your Express.js application: ```javascript // call this function after routes has been called otherwise won't works app.use((err,req,res,next)=>{ if(err) return Exception.HttpException.ExceptionHandler(err,req,res,next) // handler error and send response next() // call when no err found }) ``` 1. Customize error handling and responses as needed in your routes and controllers. ```javascript routes.all("*",Exception.HttpException.ExceptionHandler,...) ``` ## Throw an Exception ```js new Exception.HttpException({ name:"auto sugsestions",message:"",stack:"your stack must be string or a object"}) ``` Contributing ------------ We welcome contributions from the community. If you have ideas for improvements or encounter any issues, please open an [issue](https://github.com/Mullayam/exception-filter/issues) or submit a pull request. License ------- This project is licensed under the MIT License If you have any questions or need assistance, feel free to contact us at . Feel free to adapt this template to your specific project, including adding actual links, installation steps, and contact information.

近期下载者

相关文件


收藏者