fix: refactor parsedDetails initialization in AuditLogDetailModal for improved readability

This commit is contained in:
GitHub Actions
2026-02-16 19:46:25 +00:00
parent 5b3a3f41d4
commit 6944488be0
3 changed files with 13 additions and 8 deletions

View File

@@ -136,7 +136,9 @@ export const AuthProvider: FC<{ children: ReactNode }> = ({ children }) => {
: typeof error === 'object' && error !== null && 'response' in error
? (error as { response?: { data?: { error?: string } } }).response?.data?.error || 'Password change failed'
: 'Password change failed';
throw new Error(message);
throw new Error(message, {
cause: error,
});
}
};

View File

@@ -18,7 +18,9 @@ export function useDocker(host?: string | null, serverId?: string | null) {
if (error.response?.status === 503) {
const details = error.response?.data?.details
const message = details || 'Docker service unavailable. Check that Docker is running.'
throw new Error(message)
throw new Error(message, {
cause: err,
})
}
throw err
}

View File

@@ -42,12 +42,13 @@ function AuditLogDetailModal({
}) {
if (!log) return null
let parsedDetails: Record<string, unknown> = {}
try {
parsedDetails = JSON.parse(log.details)
} catch {
parsedDetails = { raw: log.details }
}
const parsedDetails: Record<string, unknown> = (() => {
try {
return JSON.parse(log.details)
} catch {
return { raw: log.details }
}
})()
return (
<Dialog open={isOpen} onOpenChange={onClose}>