Fix tag validation error messages not shown to user (#861)
This commit is contained in:
parent
782bed235b
commit
6e3b1b4099
2 changed files with 25 additions and 3 deletions
|
|
@ -1039,9 +1039,17 @@ const TaskDetails: React.FC = () => {
|
|||
);
|
||||
|
||||
setTimelineRefreshKey((prev) => prev + 1);
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
console.error('Error updating tags:', error);
|
||||
showErrorToast(t('task.tagsUpdateError', 'Failed to update tags'));
|
||||
const details = error?.details;
|
||||
if (details && Array.isArray(details) && details.length > 0) {
|
||||
showErrorToast(details.join('. '));
|
||||
} else {
|
||||
showErrorToast(
|
||||
error?.message ||
|
||||
t('task.tagsUpdateError', 'Failed to update tags')
|
||||
);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -29,7 +29,21 @@ export const handleAuthResponse = async (
|
|||
}
|
||||
throw new Error('Authentication required');
|
||||
}
|
||||
throw new Error(errorMessage);
|
||||
let details: string[] | undefined;
|
||||
try {
|
||||
const body = await response.json();
|
||||
if (body.details && Array.isArray(body.details)) {
|
||||
details = body.details;
|
||||
}
|
||||
if (body.error) {
|
||||
errorMessage = body.error;
|
||||
}
|
||||
} catch {
|
||||
// response body is not JSON, use fallback errorMessage
|
||||
}
|
||||
const error = new Error(errorMessage);
|
||||
(error as any).details = details;
|
||||
throw error;
|
||||
}
|
||||
return response;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue