pixiebrix-extension icon indicating copy to clipboard operation
pixiebrix-extension copied to clipboard

Review getRootCause call sites to ensure handling of non-error data

Open twschiller opened this issue 1 year ago • 1 comments

Context

  • getRootCause and selectSpecificError are used to walk the cause chain to
  • That's relevant because we nest errors, e.g., with ContextError
  • https://github.com/pixiebrix/pixiebrix-extension/pull/7681#discussion_r1499150288
  • cause can hold hold arbitrary data, not just errors: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause#providing_structured_data_as_the_error_cause
  • We need to double check uses of getRootCause and selectSpecificError to ensure they conceptually make sense to receive a non-error
  • I think we might need to introduce a version of getRootCause that stops once cause is not error-like
  • Errors are often passed around as "unknown", so we won't get type checker errors. The symptom will be that meaningful error messages might be dropped and instead a generic error message will show because the cause is not error-like

twschiller avatar Feb 22 '24 19:02 twschiller