txtdot/src/errors/main.ts
Artemy Egorov 6e9e9a6cc6
Plugins config (#147)
* refactor: rename configs

* refactor: create plugin config

* refactor: universal config

* fix: engine plugins default list
2024-04-27 22:15:19 +03:00

32 lines
807 B
TypeScript

import config from '../config';
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, ' +
(config.env.proxy.enabled
? 'use proxy instead of parser.'
: 'proxying is disabled by the instance admin.')
);
}
}