mirror of
https://github.com/pds-nest/nest.git
synced 2024-11-23 13:34:19 +00:00
116 lines
No EOL
2.1 KiB
JavaScript
116 lines
No EOL
2.1 KiB
JavaScript
/**
|
|
* Error thrown when a function is not implemented in the current class/instance.
|
|
*/
|
|
export class NotImplementedError {
|
|
name
|
|
|
|
constructor(name) {
|
|
this.name = name
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* An error in the N.E.S.T. frontend-backend communication.
|
|
*/
|
|
export class BackendCommunicationError {
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
* Error thrown when trying to access a backend view which doesn't exist or isn't allowed in the used hook.
|
|
*/
|
|
export class ViewNotAllowedError extends BackendCommunicationError {
|
|
view
|
|
|
|
constructor(view) {
|
|
super()
|
|
|
|
this.view = view
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* Error thrown when trying to access a backend view when outside a {@link ContextServer}.
|
|
*/
|
|
export class ServerNotConfiguredError extends BackendCommunicationError {
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
* Error thrown when trying to access a backend view while another access is ongoing.
|
|
*
|
|
* This is not allowed due to potential race conditions.
|
|
*/
|
|
export class FetchAlreadyRunningError extends BackendCommunicationError {
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
* Abstract class for {@link DecodeError} and {@link ResultError}.
|
|
*/
|
|
export class FetchError extends BackendCommunicationError {
|
|
status
|
|
statusText
|
|
|
|
constructor(status, statusText) {
|
|
super()
|
|
|
|
this.status = status
|
|
this.statusText = statusText
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* Error thrown when the frontend can't parse the data received from the backend.
|
|
*/
|
|
export class DecodeError extends FetchError {
|
|
error
|
|
|
|
constructor(status, statusText, error) {
|
|
super(status, statusText)
|
|
|
|
this.error = error
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* Error thrown when the backend returns a falsy `"result"` value.
|
|
*/
|
|
export class ResultError extends FetchError {
|
|
status
|
|
statusText
|
|
data
|
|
|
|
constructor(status, statusText, data) {
|
|
super(status, statusText)
|
|
|
|
this.data = data
|
|
}
|
|
|
|
getMsg() {
|
|
return this.data.msg
|
|
}
|
|
|
|
getCode() {
|
|
return this.data.code
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* Error thrown when a string couldn't be serialized into an object.
|
|
*/
|
|
export class SerializationError {
|
|
invalidString
|
|
|
|
constructor(invalidString) {
|
|
this.invalidString = invalidString
|
|
}
|
|
} |