Use common getConfig()
This commit is contained in:
parent
f56b79c563
commit
86c033bdaa
@ -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
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -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."
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user