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 { getFastifyError } from "./validation";
|
||||||
|
|
||||||
import { IGetSchema } from "../types/requests/browser";
|
import { IGetSchema } from "../types/requests/browser";
|
||||||
|
import getConfig from "../config/main";
|
||||||
|
|
||||||
export default function errorHandler(
|
export default function errorHandler(
|
||||||
error: Error,
|
error: Error,
|
||||||
@ -54,7 +55,10 @@ function htmlErrorHandler(error: Error, reply: FastifyReply, url: string) {
|
|||||||
url,
|
url,
|
||||||
code: error.code,
|
code: error.code,
|
||||||
description: error.description,
|
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 {
|
export abstract class TxtDotError extends Error {
|
||||||
code: number;
|
code: number;
|
||||||
name: string;
|
name: string;
|
||||||
@ -40,7 +42,11 @@ export class NotHtmlMimetypeError extends TxtDotError {
|
|||||||
super(
|
super(
|
||||||
421,
|
421,
|
||||||
"NotHtmlMimetypeError",
|
"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