You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
112 lines
3.2 KiB
112 lines
3.2 KiB
import { CodeError } from '$libs/errs';
|
|
import {
|
|
CONN_ERR_CHANNEL_ALREADY_EXISTS,
|
|
CONN_ERR_CHANNEL_NOT_FOUND,
|
|
CONN_ERR_CONNECTION_ALREADY_EXISTS,
|
|
CONN_ERR_CONNECTION_NOT_FOUND,
|
|
CONN_ERR_DISPOSED,
|
|
CONN_ERR_INVALID_CONNECTION_NAME,
|
|
CONN_ERR_INVALID_FRAME,
|
|
CONN_ERR_WEBSOCKET_UNAVAILABLE
|
|
} from './consts.ts';
|
|
|
|
export class ConnDisposedError extends CodeError {
|
|
constructor(message: string, options?: { cause?: unknown }) {
|
|
super(CONN_ERR_DISPOSED, { message, cause: options?.cause });
|
|
}
|
|
}
|
|
|
|
export class ConnConnectionAlreadyExistsError extends CodeError {
|
|
readonly connection: string;
|
|
constructor(message: string, connection: string) {
|
|
super(CONN_ERR_CONNECTION_ALREADY_EXISTS, { message });
|
|
this.connection = connection;
|
|
}
|
|
}
|
|
|
|
export class ConnConnectionNotFoundError extends CodeError {
|
|
readonly connection: string;
|
|
constructor(message: string, connection: string) {
|
|
super(CONN_ERR_CONNECTION_NOT_FOUND, { message });
|
|
this.connection = connection;
|
|
}
|
|
}
|
|
|
|
export class ConnInvalidConnectionNameError extends CodeError {
|
|
constructor(message: string, options?: { cause?: unknown }) {
|
|
super(CONN_ERR_INVALID_CONNECTION_NAME, { message, cause: options?.cause });
|
|
}
|
|
}
|
|
|
|
export class ConnInvalidFrameError extends CodeError {
|
|
constructor(message: string, options?: { cause?: unknown }) {
|
|
super(CONN_ERR_INVALID_FRAME, { message, cause: options?.cause });
|
|
}
|
|
}
|
|
|
|
export class ConnChannelAlreadyExistsError extends CodeError {
|
|
readonly channel: string;
|
|
constructor(message: string, channel: string) {
|
|
super(CONN_ERR_CHANNEL_ALREADY_EXISTS, { message });
|
|
this.channel = channel;
|
|
}
|
|
}
|
|
|
|
export class ConnChannelNotFoundError extends CodeError {
|
|
readonly channel: string;
|
|
constructor(message: string, channel: string) {
|
|
super(CONN_ERR_CHANNEL_NOT_FOUND, { message });
|
|
this.channel = channel;
|
|
}
|
|
}
|
|
|
|
export class ConnWebSocketUnavailableError extends CodeError {
|
|
constructor(message: string, options?: { cause?: unknown }) {
|
|
super(CONN_ERR_WEBSOCKET_UNAVAILABLE, { message, cause: options?.cause });
|
|
}
|
|
}
|
|
|
|
export function isConnDisposedError(value: unknown): value is ConnDisposedError {
|
|
return value instanceof ConnDisposedError;
|
|
}
|
|
|
|
export function isConnConnectionAlreadyExistsError(
|
|
value: unknown
|
|
): value is ConnConnectionAlreadyExistsError {
|
|
return value instanceof ConnConnectionAlreadyExistsError;
|
|
}
|
|
|
|
export function isConnConnectionNotFoundError(
|
|
value: unknown
|
|
): value is ConnConnectionNotFoundError {
|
|
return value instanceof ConnConnectionNotFoundError;
|
|
}
|
|
|
|
export function isConnInvalidConnectionNameError(
|
|
value: unknown
|
|
): value is ConnInvalidConnectionNameError {
|
|
return value instanceof ConnInvalidConnectionNameError;
|
|
}
|
|
|
|
export function isConnInvalidFrameError(value: unknown): value is ConnInvalidFrameError {
|
|
return value instanceof ConnInvalidFrameError;
|
|
}
|
|
|
|
export function isConnChannelAlreadyExistsError(
|
|
value: unknown
|
|
): value is ConnChannelAlreadyExistsError {
|
|
return value instanceof ConnChannelAlreadyExistsError;
|
|
}
|
|
|
|
export function isConnChannelNotFoundError(
|
|
value: unknown
|
|
): value is ConnChannelNotFoundError {
|
|
return value instanceof ConnChannelNotFoundError;
|
|
}
|
|
|
|
export function isConnWebSocketUnavailableError(
|
|
value: unknown
|
|
): value is ConnWebSocketUnavailableError {
|
|
return value instanceof ConnWebSocketUnavailableError;
|
|
}
|