mirror of
https://github.com/Retropex/umbrel-bitcoin.git
synced 2025-05-12 19:20:49 +02:00
16 lines
425 B
JavaScript
16 lines
425 B
JavaScript
// this safe handler is used to wrap our api methods
|
|
// so that we always fallback and return an exception if there is an error
|
|
// inside of an async function
|
|
// Mostly copied from vault/server/utils/safeHandler.js
|
|
function safeHandler(handler) {
|
|
return async(req, res, next) => {
|
|
try {
|
|
return await handler(req, res, next);
|
|
} catch (err) {
|
|
return next(err);
|
|
}
|
|
};
|
|
}
|
|
|
|
module.exports = safeHandler;
|