20 lines
513 B
TypeScript
20 lines
513 B
TypeScript
|
/**
|
||
|
* Custom error classes for network operations
|
||
|
*/
|
||
|
export class NetworkError extends Error {
|
||
|
public code?: string;
|
||
|
constructor(message?: string, code?: string) {
|
||
|
super(message);
|
||
|
this.name = 'NetworkError';
|
||
|
this.code = code;
|
||
|
Object.setPrototypeOf(this, new.target.prototype);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
export class TimeoutError extends NetworkError {
|
||
|
constructor(message?: string) {
|
||
|
super(message, 'ETIMEOUT');
|
||
|
this.name = 'TimeoutError';
|
||
|
Object.setPrototypeOf(this, new.target.prototype);
|
||
|
}
|
||
|
}
|