fix: refactor parsedDetails initialization in AuditLogDetailModal for improved readability
This commit is contained in:
@@ -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,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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}>
|
||||
|
||||
Reference in New Issue
Block a user