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

108 lines
2.2 KiB
JavaScript
Raw Normal View History

2017-08-23 20:13:45 +00:00
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'
}
}
class AccessDenied extends OAuth2Error {
constructor (msg) {
super('access_denied', msg, 403)
this.name = 'OAuth2AccessDenied'
this.logLevel = 'info'
}
}
class InvalidClient extends OAuth2Error {
constructor (msg) {
super('invalid_client', msg, 401)
this.name = 'OAuth2InvalidClient'
this.logLevel = 'info'
}
}
class InvalidGrant extends OAuth2Error {
constructor (msg) {
super('invalid_grant', msg, 400)
this.name = 'OAuth2InvalidGrant'
this.logLevel = 'info'
}
}
class InvalidRequest extends OAuth2Error {
constructor (msg) {
super('invalid_request', msg, 400)
this.name = 'OAuth2InvalidRequest'
this.logLevel = 'info'
}
}
class InvalidScope extends OAuth2Error {
constructor (msg) {
super('invalid_scope', msg, 400)
this.name = 'OAuth2InvalidScope'
this.logLevel = 'info'
}
}
class ServerError extends OAuth2Error {
constructor (msg) {
super('server_error', msg, 500)
this.name = 'OAuth2ServerError'
this.logLevel = 'error'
}
}
class UnauthorizedClient extends OAuth2Error {
constructor (msg) {
super('unauthorized_client', msg, 400)
this.name = 'OAuth2UnauthorizedClient'
this.logLevel = 'info'
}
}
class UnsupportedGrantType extends OAuth2Error {
constructor (msg) {
super('unsupported_grant_type', msg, 400)
this.name = 'OAuth2UnsupportedGrantType'
this.logLevel = 'info'
}
}
class UnsupportedResponseType extends OAuth2Error {
constructor (msg) {
super('unsupported_response_type', msg, 400)
this.name = 'OAuth2UnsupportedResponseType'
this.logLevel = 'info'
}
}
module.exports = {
OAuth2Error: OAuth2Error,
AccessDenied: AccessDenied,
InvalidClient: InvalidClient,
InvalidGrant: InvalidGrant,
InvalidRequest: InvalidRequest,
InvalidScope: InvalidScope,
ServerError: ServerError,
UnauthorizedClient: UnauthorizedClient,
UnsupportedGrantType: UnsupportedGrantType,
UnsupportedResponseType: UnsupportedResponseType
}