fix(core): Improve logging and error handling by introducing custom error classes and a global logging interface while refactoring network diagnostics methods.
This commit is contained in:
20
ts/errors.ts
Normal file
20
ts/errors.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user