mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2026-04-07 13:43:21 +08:00
fix: Backend crashes when invalid url is used
Improve error handling for flow info API
This commit is contained in:
18
backend/src/restful/response.js
Normal file
18
backend/src/restful/response.js
Normal file
@@ -0,0 +1,18 @@
|
||||
export function success(resp, data, statusCode) {
|
||||
resp.status(statusCode || 200).json({
|
||||
status: 'success',
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
export function failed(resp, error, statusCode) {
|
||||
resp.status(statusCode || 500).json({
|
||||
status: 'failed',
|
||||
error: {
|
||||
code: error.code,
|
||||
type: error.type,
|
||||
message: error.message,
|
||||
details: error.details,
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user