Refactor server errors handler

This commit is contained in:
Chocobozzz
2021-06-02 18:15:41 +02:00
parent 463206948d
commit e030bfb59d
20 changed files with 236 additions and 60 deletions

View File

@@ -6,6 +6,7 @@ export * from './debug.model'
export * from './emailer.model'
export * from './job.model'
export * from './log-level.type'
export * from './peertube-problem-document.model'
export * from './server-config.model'
export * from './server-debug.model'
export * from './server-error-code.enum'

View File

@@ -0,0 +1,32 @@
import { HttpStatusCode } from '@shared/core-utils'
import { OAuth2ErrorCode, ServerErrorCode } from './server-error-code.enum'
export interface PeerTubeProblemDocumentData {
'invalid-params'?: Record<string, Object>
originUrl?: string
keyId?: string
targetUrl?: string
actorUrl?: string
// Feeds
format?: string
url?: string
}
export interface PeerTubeProblemDocument extends PeerTubeProblemDocumentData {
type: string
title: string
detail: string
// Compat PeerTube <= 3.2
error: string
status: HttpStatusCode
docs?: string
code?: ServerErrorCode | OAuth2ErrorCode
}

View File

@@ -48,5 +48,13 @@ export const enum OAuth2ErrorCode {
*
* @see https://github.com/oauthjs/node-oauth2-server/blob/master/lib/errors/invalid-client-error.js
*/
INVALID_CLIENT = 'invalid_client'
INVALID_CLIENT = 'invalid_client',
/**
* The access token provided is expired, revoked, malformed, or invalid for other reasons
*
* @see https://github.com/oauthjs/node-oauth2-server/blob/master/lib/errors/invalid-token-error.js
*/
INVALID_TOKEN = 'invalid_token',
}