【问题标题】:Throw UnhandledEventException if the event is filtered如果事件被过滤,则抛出 UnhandledEventException
【发布时间】:2023-01-07 01:57:43
【问题描述】:

我有一个场景,在我们可以转换到新状态之前必须匹配某个过滤器。所以我设置了一个过滤器,并注册了 OnUnhandledEvent 以在事件未处理时抛出异常。不幸的是,它不会抛出任何错误。 Automatonymous 似乎将此标记为已处理,因为我们处于处理事件的正确状态。

是否有手动抛出 UnhandledException 的选项?

            During(
                this.ToBeReviewed,
                When(this.Approve, IsCreatedByOtherUserAccountId())
                    .TransitionTo(this.Approved)
                    .Then(AddUserAcceptedEvent));


            OnUnhandledEvent(x => x.Throw()); // Not working because the event is filtered above

【问题讨论】:

    标签: masstransit automatonymous


    【解决方案1】:

    您可以自己抛出异常。如果您处于处理事件的状态,则状态机不会抛出异常。

    .Then(_ => throw new UnhandledEventException);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-02-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-19
      • 1970-01-01
      • 2023-03-02
      相关资源
      最近更新 更多