You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.1 KiB
TypeScript
51 lines
1.1 KiB
TypeScript
import { STATUS_TEXTS } from '@hydrooj/utils/lib/status';
|
|
|
|
interface CompileErrorInfo {
|
|
stdout?: string,
|
|
stderr?: string,
|
|
status?: number
|
|
}
|
|
|
|
export class CompileError extends Error {
|
|
stdout: string;
|
|
stderr: string;
|
|
status: string;
|
|
type = 'CompileError';
|
|
|
|
constructor(obj: string | CompileErrorInfo) {
|
|
super('Compile Error');
|
|
if (typeof obj === 'string') {
|
|
this.stdout = obj;
|
|
this.stderr = '';
|
|
} else {
|
|
this.stdout = obj.stdout || '';
|
|
this.stderr = obj.stderr || '';
|
|
this.status = obj.status ? STATUS_TEXTS[obj.status] || '' : '';
|
|
}
|
|
}
|
|
}
|
|
|
|
export class FormatError extends Error {
|
|
type = 'FormatError';
|
|
|
|
constructor(message: string, public params = []) {
|
|
super(message);
|
|
}
|
|
}
|
|
|
|
export class RuntimeError extends Error {
|
|
type = 'RuntimeError';
|
|
|
|
constructor(public detail: string, message: string) {
|
|
super(message);
|
|
}
|
|
}
|
|
|
|
export class SystemError extends Error {
|
|
type = 'SystemError';
|
|
|
|
constructor(message: string, public params = []) {
|
|
super(message);
|
|
}
|
|
}
|