hoist-react icon indicating copy to clipboard operation
hoist-react copied to clipboard

`ErrorMessage` should provide better default behavior

Open saba-mo opened this issue 1 year ago • 2 comments

Several issues with the default behavior of errorMessage:

  1. The component offers the actionFn and detailsFn props that, when provided, will render styled Retry and Details buttons. It would be an improvement if you could set a prop to true that would not only get you the styled button but also a default function for the button's onClick. Right now you have to write the following boilerplate to get commonly used functions.
actionFn: () => model.refreshAsync()
detailsFn: () => XH.exceptionHandler.showExceptionDetails(error) 
  1. The most obvious binding choice -- errorMessage({error: model.lastLoadException}) often doesn't look good:

e.g. Model throws in doLoadAsync() with e.g. HTTP500, resulting error comes back from fetchService with empty string message, mildly-useful name. Our errorMessage component displays small empty red box - looks silly.

Should be able to better source meaningful content from exception + fallback to generic error message string if none found.

saba-mo avatar Dec 16 '23 00:12 saba-mo