From ba3527a926a99433be012a681012628294dc6105 Mon Sep 17 00:00:00 2001 From: Francisco Javier Tirado Sarti Date: Tue, 5 Mar 2024 18:03:37 +0100 Subject: [PATCH] [Fix apache/incubator-kie-issues#987] Add onError listener --- .../org/kie/api/event/process/ErrorEvent.java | 33 +++++++++++++++++++ .../event/process/ProcessEventListener.java | 6 ++++ 2 files changed, 39 insertions(+) create mode 100644 kie-api/src/main/java/org/kie/api/event/process/ErrorEvent.java diff --git a/kie-api/src/main/java/org/kie/api/event/process/ErrorEvent.java b/kie-api/src/main/java/org/kie/api/event/process/ErrorEvent.java new file mode 100644 index 00000000000..af2cc4e0568 --- /dev/null +++ b/kie-api/src/main/java/org/kie/api/event/process/ErrorEvent.java @@ -0,0 +1,33 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.api.event.process; + +import org.kie.api.runtime.process.NodeInstance; + +/** + * An event when a error is thrown + */ +public interface ErrorEvent extends ProcessNodeEvent { + /** + * Error associated to the event + * + * @return exception + */ + Exception getException(); +} diff --git a/kie-api/src/main/java/org/kie/api/event/process/ProcessEventListener.java b/kie-api/src/main/java/org/kie/api/event/process/ProcessEventListener.java index 4f27158b6b1..085f7a34a3b 100644 --- a/kie-api/src/main/java/org/kie/api/event/process/ProcessEventListener.java +++ b/kie-api/src/main/java/org/kie/api/event/process/ProcessEventListener.java @@ -116,4 +116,10 @@ default void onSignal(SignalEvent event) {} * @param event */ default void onMessage(MessageEvent event) {} + + /** + * This listener method is invoked when an error is captured + * @param event + */ + default void onError (ErrorEvent event) {} }