txtdot/packages/server/src/errors/main.ts

32 lines
789 B
TypeScript
Raw Normal View History

import config from '../config';
2024-05-13 12:54:14 +03:00
import { TxtDotError } from '@txtdot/sdk';
2023-08-21 17:35:25 +03:00
export class LocalResourceError extends TxtDotError {
constructor() {
super(403, 'LocalResourceError', 'Proxying local resources is forbidden.');
2023-08-21 17:35:25 +03:00
}
}
2023-08-21 16:03:28 +03:00
2024-03-07 14:49:54 +03:00
export class UnsupportedMimetypeError extends TxtDotError {
constructor(expected: string, got?: string) {
super(
415,
'UnsupportedMimetypeError',
`Unsupported mimetype, expected ${expected}, got ${got}`
);
}
}
2023-09-21 12:18:12 +03:00
export class NotHtmlMimetypeError extends TxtDotError {
constructor() {
super(
421,
'NotHtmlMimetypeError',
'Received non-HTML content, ' +
(config.env.proxy.enabled
? 'use proxy instead of parser.'
: 'proxying is disabled by the instance admin.')
2023-09-21 12:18:12 +03:00
);
2023-08-16 13:20:24 +03:00
}
}