mirror of
https://github.com/EFForg/rayhunter.git
synced 2026-05-31 02:03:35 -07:00
56122f6559
This error reporting comes in two forms: - Errors updating the UI - Errors with user actions The former is displayed as one error until a refresh succeeds again. The latter creates an number of persistent errors until they are cleared by the user.
25 lines
695 B
TypeScript
25 lines
695 B
TypeScript
export class ActionError extends Error {
|
|
// The number of this an identical error has happened.
|
|
// This is shown as a number next to the error in the UI.
|
|
times = $state(1);
|
|
|
|
constructor(message: string, cause: Error) {
|
|
super(message);
|
|
this.cause = cause;
|
|
}
|
|
}
|
|
|
|
export const action_errors: ActionError[] = $state([]);
|
|
|
|
export function add_error(e: Error, msg: string): void {
|
|
for (const existing of action_errors) {
|
|
if (existing.message === msg) {
|
|
existing.times += 1;
|
|
return;
|
|
}
|
|
}
|
|
const action_error = new ActionError(msg, e);
|
|
action_errors.unshift(action_error);
|
|
console.log(action_errors.length);
|
|
}
|