This repository has been archived on 2022-11-26. You can view files and clone it, but cannot push or open issues or pull requests.
IcyNet.eu/server/api/oauth2/error.js

95 lines
1.9 KiB
JavaScript

export class OAuth2Error extends Error {
constructor (code, msg, status) {
super()
Error.captureStackTrace(this, this.constructor)
this.code = code
this.message = msg
this.status = status
this.name = 'OAuth2AbstractError'
this.logLevel = 'error'
}
}
export class AccessDenied extends OAuth2Error {
constructor (msg) {
super('access_denied', msg, 403)
this.name = 'OAuth2AccessDenied'
this.logLevel = 'info'
}
}
export class InvalidClient extends OAuth2Error {
constructor (msg) {
super('invalid_client', msg, 401)
this.name = 'OAuth2InvalidClient'
this.logLevel = 'info'
}
}
export class InvalidGrant extends OAuth2Error {
constructor (msg) {
super('invalid_grant', msg, 400)
this.name = 'OAuth2InvalidGrant'
this.logLevel = 'info'
}
}
export class InvalidRequest extends OAuth2Error {
constructor (msg) {
super('invalid_request', msg, 400)
this.name = 'OAuth2InvalidRequest'
this.logLevel = 'info'
}
}
export class InvalidScope extends OAuth2Error {
constructor (msg) {
super('invalid_scope', msg, 400)
this.name = 'OAuth2InvalidScope'
this.logLevel = 'info'
}
}
export class ServerError extends OAuth2Error {
constructor (msg) {
super('server_error', msg, 500)
this.name = 'OAuth2ServerError'
this.logLevel = 'error'
}
}
export class UnauthorizedClient extends OAuth2Error {
constructor (msg) {
super('unauthorized_client', msg, 400)
this.name = 'OAuth2UnauthorizedClient'
this.logLevel = 'info'
}
}
export class UnsupportedGrantType extends OAuth2Error {
constructor (msg) {
super('unsupported_grant_type', msg, 400)
this.name = 'OAuth2UnsupportedGrantType'
this.logLevel = 'info'
}
}
export class UnsupportedResponseType extends OAuth2Error {
constructor (msg) {
super('unsupported_response_type', msg, 400)
this.name = 'OAuth2UnsupportedResponseType'
this.logLevel = 'info'
}
}