admin: nicer EPERM message
Massimo Melina committed
Aug 1, 2025 at 12:13 UTC
bfef4befea221fe3f3a9ef6d8016eefcd5a51205
2 files changed
+6
-3
admin/src/dialog.ts
+1
-1
@@ -83,7 +83,7 @@ export function alertDialog(msg: ReactElement | string | Error, options?: AlertT
83
const opt = typeof options === 'string' ? { type: options } : (options ?? {})
84
let { type='info', ...rest } = opt
85
if (msg instanceof Error) {
86
- msg = msg.message || String(err2msg((msg as any).code))
86
+ msg = err2msg(msg.message || (msg as any).code)
87
type = 'error'
88
}
89
admin/src/misc.ts
+5
-2
@@ -15,12 +15,15 @@ export async function manipulateConfig(k: string, work:(data:any) => any) {
15
await apiCall('set_config', { values: { [k]: will } })
16
}
17
18
-export function err2msg(code: string) {
18
+export function err2msg(code: string | number) {
19
+ const permPath = typeof code === 'string' && code.split("Error: EPERM: operation not permitted, access ")[1]?.split('\n')[0]
20
+ if (permPath)
21
+ return `Access denied on disk for ${permPath}`
22
return {
23
github_quota: "Request denied. You may have reached the limit, retry later.",
24
ENOENT: "Not found",
25
ENOTDIR: "Not a folder",
23
- }[code] || HTTP_MESSAGES[code as any] || code
26
+ }[code] || HTTP_MESSAGES[code as any] || String(code)
27
}
28
29
export function formatTimestamp(x: number | string | Date) {