txtdot/src/errors/main.ts
Artemy Egorov 8f707c800e
Timeout (#70)
* fix: long response time due to many <a>...

... without hrefs. It's a temporary measure until it's clear how to deal with such performance issues.

* perf: remove jsdom install linkedom

* feat: timeout

But still this timeout works only for the time of transfer of the page itself, not its processing by the server

* fix: links

* format
2023-12-13 21:08:24 +04:00

40 lines
947 B
TypeScript

import getConfig from '../config/main';
export abstract class TxtDotError extends Error {
code: number;
name: string;
description: string;
constructor(code: number, name: string, description: string) {
super(description);
this.code = code;
this.name = name;
this.description = description;
}
}
export class EngineParseError extends TxtDotError {
constructor(message: string) {
super(422, 'EngineParseError', `Parse error: ${message}`);
}
}
export class LocalResourceError extends TxtDotError {
constructor() {
super(403, 'LocalResourceError', 'Proxying local resources is forbidden.');
}
}
export class NotHtmlMimetypeError extends TxtDotError {
constructor() {
super(
421,
'NotHtmlMimetypeError',
'Received non-HTML content, ' +
(getConfig().proxy_res
? 'use proxy instead of parser.'
: 'proxying is disabled by the instance admin.')
);
}
}