aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/models/server
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-06-02 18:15:41 +0200
committerChocobozzz <me@florianbigard.com>2021-06-02 18:15:41 +0200
commite030bfb59dd5ee65f20a64686ec9b22ca39f70ae (patch)
treec9a439159ef540291e3c030bcaf958b953442147 /shared/models/server
parent463206948d6a9d46e7e68d55c7b763e601ecc870 (diff)
downloadPeerTube-e030bfb59dd5ee65f20a64686ec9b22ca39f70ae.tar.gz
PeerTube-e030bfb59dd5ee65f20a64686ec9b22ca39f70ae.tar.zst
PeerTube-e030bfb59dd5ee65f20a64686ec9b22ca39f70ae.zip
Refactor server errors handler
Diffstat (limited to 'shared/models/server')
-rw-r--r--shared/models/server/index.ts1
-rw-r--r--shared/models/server/peertube-problem-document.model.ts32
-rw-r--r--shared/models/server/server-error-code.enum.ts10
3 files changed, 42 insertions, 1 deletions
diff --git a/shared/models/server/index.ts b/shared/models/server/index.ts
index b5163954a..06bf5c599 100644
--- a/shared/models/server/index.ts
+++ b/shared/models/server/index.ts
@@ -6,6 +6,7 @@ export * from './debug.model'
6export * from './emailer.model' 6export * from './emailer.model'
7export * from './job.model' 7export * from './job.model'
8export * from './log-level.type' 8export * from './log-level.type'
9export * from './peertube-problem-document.model'
9export * from './server-config.model' 10export * from './server-config.model'
10export * from './server-debug.model' 11export * from './server-debug.model'
11export * from './server-error-code.enum' 12export * from './server-error-code.enum'
diff --git a/shared/models/server/peertube-problem-document.model.ts b/shared/models/server/peertube-problem-document.model.ts
new file mode 100644
index 000000000..5e1c320f3
--- /dev/null
+++ b/shared/models/server/peertube-problem-document.model.ts
@@ -0,0 +1,32 @@
1import { HttpStatusCode } from '@shared/core-utils'
2import { OAuth2ErrorCode, ServerErrorCode } from './server-error-code.enum'
3
4export interface PeerTubeProblemDocumentData {
5 'invalid-params'?: Record<string, Object>
6
7 originUrl?: string
8
9 keyId?: string
10
11 targetUrl?: string
12
13 actorUrl?: string
14
15 // Feeds
16 format?: string
17 url?: string
18}
19
20export interface PeerTubeProblemDocument extends PeerTubeProblemDocumentData {
21 type: string
22 title: string
23
24 detail: string
25 // Compat PeerTube <= 3.2
26 error: string
27
28 status: HttpStatusCode
29
30 docs?: string
31 code?: ServerErrorCode | OAuth2ErrorCode
32}
diff --git a/shared/models/server/server-error-code.enum.ts b/shared/models/server/server-error-code.enum.ts
index 93b9ce20d..43996e7aa 100644
--- a/shared/models/server/server-error-code.enum.ts
+++ b/shared/models/server/server-error-code.enum.ts
@@ -48,5 +48,13 @@ export const enum OAuth2ErrorCode {
48 * 48 *
49 * @see https://github.com/oauthjs/node-oauth2-server/blob/master/lib/errors/invalid-client-error.js 49 * @see https://github.com/oauthjs/node-oauth2-server/blob/master/lib/errors/invalid-client-error.js
50 */ 50 */
51 INVALID_CLIENT = 'invalid_client' 51 INVALID_CLIENT = 'invalid_client',
52
53
54 /**
55 * The access token provided is expired, revoked, malformed, or invalid for other reasons
56 *
57 * @see https://github.com/oauthjs/node-oauth2-server/blob/master/lib/errors/invalid-token-error.js
58 */
59 INVALID_TOKEN = 'invalid_token',
52} 60}