feat: better error message display (#17477)

This commit is contained in:
Tsuyumi 2024-11-07 01:55:12 +08:00 committed by GitHub
parent 2d1c6cc2e9
commit 40bab08529
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 4 deletions

View File

@ -3,8 +3,8 @@ import { config } from '@/config';
import md5 from '@/utils/md5';
import RejectError from '@/errors/types/reject';
const reject = () => {
throw new RejectError('Authentication failed. Access denied.');
const reject = (requestPath) => {
throw new RejectError(`Authentication failed. Access denied.\n${requestPath}`);
};
const middleware: MiddlewareHandler = async (ctx, next) => {
@ -16,7 +16,7 @@ const middleware: MiddlewareHandler = async (ctx, next) => {
await next();
} else {
if (config.accessKey && !(config.accessKey === accessKey || accessCode === md5(requestPath + config.accessKey))) {
return reject();
return reject(requestPath);
}
await next();
}

View File

@ -26,7 +26,7 @@ const Index: FC<{
<p className="message">
Error Message:
<br />
<code className="mt-2 block max-h-28 overflow-auto bg-zinc-100 align-bottom w-fit details">{message}</code>
<code className="mt-2 block max-h-28 overflow-auto bg-zinc-100 align-bottom w-fit details whitespace-pre-line">{message}</code>
</p>
<p className="message">
Route: <code className="ml-2 bg-zinc-100">{errorRoute}</code>