diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2021-06-01 01:36:53 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2021-06-02 16:57:07 +0200 |
commit | 76148b27f7501bac061992136852be4303370c8d (patch) | |
tree | fc0559253e833c9252fa14ebaec5321d88bfb4e8 /server/controllers/api/users/token.ts | |
parent | 5ed25fb76e920dac364cb9ef46f14ec4bd372949 (diff) | |
download | PeerTube-76148b27f7501bac061992136852be4303370c8d.tar.gz PeerTube-76148b27f7501bac061992136852be4303370c8d.tar.zst PeerTube-76148b27f7501bac061992136852be4303370c8d.zip |
refactor API errors to standard error format
Diffstat (limited to 'server/controllers/api/users/token.ts')
-rw-r--r-- | server/controllers/api/users/token.ts | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/server/controllers/api/users/token.ts b/server/controllers/api/users/token.ts index 694bb0a92..863a3d74c 100644 --- a/server/controllers/api/users/token.ts +++ b/server/controllers/api/users/token.ts | |||
@@ -78,9 +78,10 @@ async function handleToken (req: express.Request, res: express.Response, next: e | |||
78 | } catch (err) { | 78 | } catch (err) { |
79 | logger.warn('Login error', { err }) | 79 | logger.warn('Login error', { err }) |
80 | 80 | ||
81 | return res.status(err.code || 400).json({ | 81 | return res.fail({ |
82 | code: err.name, | 82 | status: err.code, |
83 | error: err.message | 83 | message: err.message, |
84 | type: err.name | ||
84 | }) | 85 | }) |
85 | } | 86 | } |
86 | } | 87 | } |