File tree Expand file tree Collapse file tree 2 files changed +18
-6
lines changed Expand file tree Collapse file tree 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 => {
115115 return error . detail ;
116116 }
117117
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 ) {
123122 return error . response . data . detail ;
124123 }
125124
126- if ( isApiErrorResponse ( error ) ) {
125+ if ( isApiErrorResponse ( error ) && error . detail ) {
127126 return error . detail ;
128127 }
129128
129+ if ( error instanceof Error ) {
130+ return "Please check the developer console for more details." ;
131+ }
132+
130133 return undefined ;
131134} ;
132135
Original file line number Diff line number Diff line change @@ -34,6 +34,15 @@ export const WithOnlyMessage: Story = {
3434 } ,
3535} ;
3636
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+
3746export const WithDismiss : Story = {
3847 args : {
3948 dismissible : true ,
You can’t perform that action at this time.
0 commit comments