Comments (3)
@veyselboybay what do you think about this one? Say we have a middleware like
app.use((err, req, res, next) => {
const statusCode = err.statusCode || 500;
logger.error(err.message, { service: error.service });
res.status(statusCode).json({ success: false, msg: err.message });
});
We can pass any errors from the controllers/other middleware to the error handler:
try{
...
} catch (error) {
error.statusCode = 404
error.service = "Auth Service"
next(error)
}
Something like that?
We can cut down on some repeated code in the controllers/middleware and keep error handling centralized as well
from bluewave-uptime.
Sure, I'll try putting it together and see how it works
from bluewave-uptime.
This looks like a great idea and seems like the best practice. Have you got a chance to test it?
from bluewave-uptime.
Related Issues (20)
- Backend - Process invites
- Redux - Track latest status checks
- 404 Pages HOT 24
- Monitor Checks Sort Order HOT 1
- Current monitors table shall include type of the monitor
- Slight changes in dashboard HOT 8
- FE & BE - Invite Register with Token
- FE - Update role from string to array
- Incidents fallback
- Frontend - PageSpeed UI HOT 2
- BE - PageSpeed Database Methods
- Design - Small BWL Logo for Favicon and Menu
- Design - Responsive Design
- Frontend - Loading component HOT 1
- FE & BE - Update FE requests and BE endpoints to allow for different monitor types
- BE - Refatctor Monitor Endpoints
- FE - Create Monitor Add Pagespeed Type
- BE - Add maintenance window DB entity & DB opertions module
- BE - Check for maintenance window before executing job
- Devops - Automate fetching of code and rebuilding Docker images when commit to Master is made
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bluewave-uptime.