txtdot/src/errors/main.ts
Artemy Egorov c04ea407ae
Plugins (#146)
* refactor: move engines to the sdk

* refactor: move engines to plugins

* refactor: move engines to plugins

* fix: prettier
2024-04-27 16:21:41 +00:00

32 lines
816 B
TypeScript

import getConfig from '../config/main';
import { TxtDotError } from '@txtdot/sdk/dist/types/errors';
export class LocalResourceError extends TxtDotError {
constructor() {
super(403, 'LocalResourceError', 'Proxying local resources is forbidden.');
}
}
export class UnsupportedMimetypeError extends TxtDotError {
constructor(expected: string, got?: string) {
super(
415,
'UnsupportedMimetypeError',
`Unsupported mimetype, expected ${expected}, got ${got}`
);
}
}
export class NotHtmlMimetypeError extends TxtDotError {
constructor() {
super(
421,
'NotHtmlMimetypeError',
'Received non-HTML content, ' +
(getConfig().proxy.enabled
? 'use proxy instead of parser.'
: 'proxying is disabled by the instance admin.')
);
}
}