fix: proper TypeScript type assertion for error object
- Use type assertion to define error object structure - Use optional chaining for safe property access - Maintain all error handling functionality Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
@@ -227,11 +227,12 @@ function SettingsForm({ me, onBack }: { me: MemberRead; onBack: () => void }) {
|
||||
} else if (err.message.includes('422')) {
|
||||
errorMessage = 'Invalid image file. Please upload a valid image (JPG, PNG, etc.).';
|
||||
}
|
||||
} else if (typeof err === 'object' && err !== null && 'status' in err && 'data' in err) {
|
||||
} else if (typeof err === 'object' && err !== null) {
|
||||
// Try to extract more details from the error object
|
||||
console.error("Error details:", JSON.stringify(err));
|
||||
if (err.status === 422 && err.data && 'detail' in err.data) {
|
||||
errorMessage = err.data.detail;
|
||||
const errorObj = err as { status?: number; data?: { detail?: string } };
|
||||
if (errorObj.status === 422 && errorObj.data?.detail) {
|
||||
errorMessage = errorObj.data.detail;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user