Skip to content
Discussion options

You must be logged in to vote

Hey @Lao-Ax - you might want to try createActionTrackingMiddleware2 for this instead. It gives you a cleaner start/finish api surface for actions, and you can write something like this:

  const middleware = createActionTrackingMiddleware2({
    filter() {
      return true;
    },
    onStart() {},
    onFinish(call, error) {
      if (error && !call.parentCall) {
        console.warn(
          `[ERROR] ${call.name} (${getPath(call.context)}): ${error instanceof Error ? error.message : error}`
        );
      }
    },
  });

  addMiddleware(store, middleware);

Which will check if there's an error in the call, and you can then check if the call had a parent, and only lift the error up once.

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@Lao-Ax
Comment options

@Lao-Ax
Comment options

@coolsoftwaretyler
Comment options

@coolsoftwaretyler
Comment options

Answer selected by coolsoftwaretyler
@Lao-Ax
Comment options

@Lao-Ax
Comment options

@coolsoftwaretyler
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants