2020-07-21 13:20:51 +00:00
|
|
|
import {OpenDocMode} from 'app/common/DocListAPI';
|
|
|
|
|
|
|
|
interface ErrorDetails {
|
|
|
|
status?: number;
|
|
|
|
accessMode?: OpenDocMode;
|
2021-02-15 21:36:33 +00:00
|
|
|
memos?: string[];
|
2020-07-21 13:20:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* An error with a human-readable message and a machine-readable code.
|
|
|
|
* Makes it easier to change the human-readable message without breaking
|
|
|
|
* error handlers.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
export class ErrorWithCode extends Error {
|
2021-02-15 21:36:33 +00:00
|
|
|
constructor(public code: string, message: string, public details: ErrorDetails = {}) {
|
2020-07-21 13:20:51 +00:00
|
|
|
super(message);
|
|
|
|
}
|
2021-02-15 21:36:33 +00:00
|
|
|
public get accessMode() { return this.details?.accessMode; }
|
|
|
|
public get status() { return this.details?.status; }
|
2020-07-21 13:20:51 +00:00
|
|
|
}
|