Handling errors

I would like to alert my users when something goes wrong, and also do some reporting to our backend. Is there a recommended way to do this?

I have been using this:

dispatchTransaction(transaction) {
  try {
    const newState = view.state.apply(transaction);
  } catch (error) {
    alert('Sorry, your last action failed. Please try again.');

It works, but I am wondering if there is a better way to handle it?


ProseMirror does not have a built-in exception-routing mechanism or similar, so no, I don’t know of a better way to do this.

Okay, thanks @marijn. Your library is stunning, by the way. I’m genuinely impressed by how powerful the building blocks you provided are!