File tree 2 files changed +18
-6
lines changed
2 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -115,18 +115,21 @@ export const getErrorDetail = (error: unknown): string | undefined => {
115
115
return error . detail ;
116
116
}
117
117
118
- if ( error instanceof Error ) {
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 ) {
123
122
return error . response . data . detail ;
124
123
}
125
124
126
- if ( isApiErrorResponse ( error ) ) {
125
+ if ( isApiErrorResponse ( error ) && error . detail ) {
127
126
return error . detail ;
128
127
}
129
128
129
+ if ( error instanceof Error ) {
130
+ return "Please check the developer console for more details." ;
131
+ }
132
+
130
133
return undefined ;
131
134
} ;
132
135
Original file line number Diff line number Diff line change @@ -34,6 +34,15 @@ export const WithOnlyMessage: Story = {
34
34
} ,
35
35
} ;
36
36
37
+ export const APIErrorWithDetail : 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
+
37
46
export const WithDismiss : Story = {
38
47
args : {
39
48
dismissible : true ,
You can’t perform that action at this time.
0 commit comments