Skip to content

Commit

Permalink
feat: better error message display (#17477)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tsuyumi25 authored Nov 6, 2024
1 parent 2d1c6cc commit 40bab08
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/middleware/access-control.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion lib/views/error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit 40bab08

Please sign in to comment.