Use common getConfig()

This commit is contained in:
DarkCat09 2023-09-21 16:32:08 +04:00
parent f56b79c563
commit 86c033bdaa
No known key found for this signature in database
GPG Key ID: 0A26CD5B3345D6E3
2 changed files with 12 additions and 2 deletions

View File

@ -3,6 +3,7 @@ import { NotHtmlMimetypeError, TxtDotError } from "./main";
import { getFastifyError } from "./validation";
import { IGetSchema } from "../types/requests/browser";
import getConfig from "../config/main";
export default function errorHandler(
error: Error,
@ -54,7 +55,10 @@ function htmlErrorHandler(error: Error, reply: FastifyReply, url: string) {
url,
code: error.code,
description: error.description,
proxyBtn: error instanceof NotHtmlMimetypeError,
proxyBtn: (
error instanceof NotHtmlMimetypeError &&
getConfig().proxy_res
),
});
}

View File

@ -1,3 +1,5 @@
import getConfig from "../config/main";
export abstract class TxtDotError extends Error {
code: number;
name: string;
@ -40,7 +42,11 @@ export class NotHtmlMimetypeError extends TxtDotError {
super(
421,
"NotHtmlMimetypeError",
"Received non-HTML content, use proxy",
"Received non-HTML content, " + (
getConfig().proxy_res ?
"use proxy instead of parser." :
"proxying is disabled by the instance admin."
),
);
}
}