Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit755afa3

Browse files
authored
chore: ui error handling should be specific to general (#14346)
* chore: ui error handling should be specific to generalSpecific errors should be checked before defaulting to a generalerror handling
1 parent422e044 commit755afa3

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

‎site/src/api/errors.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,18 +115,21 @@ export const getErrorDetail = (error: unknown): string | undefined => {
115115
returnerror.detail;
116116
}
117117

118-
if(errorinstanceofError){
119-
return"Please check the developer console for more details.";
120-
}
121-
122-
if(isApiError(error)){
118+
// APIErrors that are empty still benefit from checking the developer
119+
// console if no detail is provided. So only use the detail field if
120+
// it is not empty.
121+
if(isApiError(error)&&error.response.data.detail){
123122
returnerror.response.data.detail;
124123
}
125124

126-
if(isApiErrorResponse(error)){
125+
if(isApiErrorResponse(error)&&error.detail){
127126
returnerror.detail;
128127
}
129128

129+
if(errorinstanceofError){
130+
return"Please check the developer console for more details.";
131+
}
132+
130133
returnundefined;
131134
};
132135

‎site/src/components/Alert/ErrorAlert.stories.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ export const WithOnlyMessage: Story = {
3434
},
3535
};
3636

37+
exportconstAPIErrorWithDetail:Story={
38+
args:{
39+
error:mockApiError({
40+
message:"Magic dust is missing",
41+
detail:"without magic dust, the requested operation will never work",
42+
}),
43+
},
44+
};
45+
3746
exportconstWithDismiss:Story={
3847
args:{
3948
dismissible:true,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp