-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
53 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
class NeisError extends Error {} | ||
|
||
class HTTPError extends NeisError { | ||
constructor(code: string, msg: string) { | ||
super(`${code}: ${msg}`) | ||
this.name = this.constructor.name | ||
} | ||
} | ||
|
||
export class MissingRequiredValueError extends HTTPError {} | ||
|
||
export class AuthenticationError extends HTTPError {} | ||
|
||
export class ServiceNotFoundError extends HTTPError {} | ||
|
||
export class InvalidLocationValueError extends HTTPError {} | ||
|
||
export class RequestLimitExceededError extends HTTPError {} | ||
|
||
export class DailyTrafficLimitExceededError extends HTTPError {} | ||
|
||
export class ServerError extends HTTPError {} | ||
|
||
export class DatabaseConnectionError extends HTTPError {} | ||
|
||
export class SQLStatementError extends HTTPError {} | ||
|
||
export class LimitUseAuthenticationKeyError extends HTTPError {} | ||
|
||
export class DataNotFoundError extends HTTPError {} | ||
|
||
export const ErrorsMapping: { | ||
[key: string]: new (code: string, msg: string) => NeisError | ||
} = { | ||
'ERROR-300': MissingRequiredValueError, | ||
'ERROR-290': AuthenticationError, | ||
'ERROR-310': ServiceNotFoundError, | ||
'ERROR-333': InvalidLocationValueError, | ||
'ERROR-336': RequestLimitExceededError, | ||
'ERROR-337': DailyTrafficLimitExceededError, | ||
'ERROR-500': ServerError, | ||
'ERROR-600': DatabaseConnectionError, | ||
'ERROR-601': SQLStatementError, | ||
'INFO-300': LimitUseAuthenticationKeyError, | ||
'INFO-200': DataNotFoundError, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './client' | ||
export * from './errors' | ||
export * from './types' |