28 lines
559 B
TypeScript
28 lines
559 B
TypeScript
import { NetIdType } from 'tornado-scripts';
|
|
|
|
export interface ErrorTypes {
|
|
type: string;
|
|
netId: number;
|
|
timestamp: number;
|
|
}
|
|
|
|
export interface ErrorMessages extends ErrorTypes {
|
|
message?: string;
|
|
stack?: string;
|
|
}
|
|
|
|
export function newError(
|
|
type: string,
|
|
netId: NetIdType,
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
err: any,
|
|
): ErrorMessages {
|
|
return {
|
|
type,
|
|
netId,
|
|
timestamp: Math.floor(Date.now() / 1000),
|
|
message: err.message,
|
|
stack: err.stack,
|
|
};
|
|
}
|