fix(frontend): guard response.error.includes against non-string error values
If the API returns a non-string error (e.g. numeric HTTP status code), calling .includes() directly on it throws "N.includes is not a function". Convert to string via JSON.stringify first. Fixes save button crash on rules/new page. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -855,10 +855,11 @@ export default function RuleNew() {
|
||||
}
|
||||
|
||||
if (response.error) {
|
||||
if (response.error.includes('evaluation_points_code_key')) {
|
||||
const errorStr = typeof response.error === 'string' ? response.error : JSON.stringify(response.error);
|
||||
if (errorStr.includes('evaluation_points_code_key')) {
|
||||
toastService.error('在基本信息中:评查点编码已存在,请修改后保存。');
|
||||
} else {
|
||||
toastService.error(`系统繁忙: ${response.error}`);
|
||||
toastService.error(`系统繁忙: ${errorStr}`);
|
||||
}
|
||||
setIsLoading(false);
|
||||
} else if (response.data) {
|
||||
|
||||
Reference in New Issue
Block a user