notifyThrown()function

notifyThrown(thrown: unknown, el?: EventTarget): void
ParamType
thrownunknown
The thrown value to report. required
elEventTarget
Element to dispatch the event on (defaults to window).

Look at a thrown value, extract a viable message from it, and dispatch an error notice.

  • Uses getMessage() to pull a human-readable string from the thrown value.
  • Falls back to a generic "Unknown error" notice and console.error() when no message can be extracted.

Examples

try { await save(); } catch (thrown) { notifyThrown(thrown); }