diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-10-26 14:38:34 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-10-26 14:38:34 +0900 |
| commit | 02b47f963c00647407ceda721f0313d59e7bdbd4 (patch) | |
| tree | b432a0472d5008422a1ec92117756e1cf1e3a569 /src/server/api/call.ts | |
| parent | Improve usability (diff) | |
| download | sharkey-02b47f963c00647407ceda721f0313d59e7bdbd4.tar.gz sharkey-02b47f963c00647407ceda721f0313d59e7bdbd4.tar.bz2 sharkey-02b47f963c00647407ceda721f0313d59e7bdbd4.zip | |
API: Better error response
Diffstat (limited to 'src/server/api/call.ts')
| -rw-r--r-- | src/server/api/call.ts | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/server/api/call.ts b/src/server/api/call.ts index 20cb1ab7d5..b87707c348 100644 --- a/src/server/api/call.ts +++ b/src/server/api/call.ts @@ -62,7 +62,15 @@ export default (endpoint: string, user: IUser, app: IApp, data: any, file?: any) console.warn(`SLOW API CALL DETECTED: ${ep.name} (${time}ms)`); } } catch (e) { - rej(e.message); + if (e.name == 'INVALID_PARAM') { + rej({ + code: e.name, + param: e.param, + reason: e.message + }); + } else { + rej(e); + } return; } |