Hi all

In the exception handling of new ivy (6.0) we have a new term that is BpmError, i'm catching it but now i want to know what is the rootcause of that exception, so how can i get it from BpmError. Here is the stacktrace of exception: alt text

The read box is the root cause actually that i want to get it out.

Is there any way?

Thanks

asked 07.12.2016 at 12:05

trungdv's gravatar image

trungdv
(suspended)
accept rate: 52%

edited 07.12.2016 at 12:06


The method error.getTechnicalCause() returns the origin thrown exception in the Process Engine. To get the 'root' exception call the method Throwable.getCause() as many times as necessary...

public class BpmErrorUtils {
    public static Throwable getRootCause(BpmError bpmError) {
        Throwable origin = bpmError.getTechnicalCause();
        Throwable parent = origin.getCause();
        while (parent != null) {
            origin = parent;
            parent = origin.getCause();
        }
        return origin;
    }
}
link

answered 08.12.2016 at 14:49

Flavio%20Sadeghi's gravatar image

Flavio Sadeghi ♦♦
(suspended)
accept rate: 75%

yes, i came up with the similar solution:

   public class CauseFinder {
            private Predicate<Throwable> predicate;

        public CauseFinder(Predicate<Throwable> predicate) {

                       this.predicate = predicate;

          }
         public Throwable findCause(Throwable throwable) {

               Throwable cause = throwable.getCause();

               return cause == null || (cause != null && cause.equals(throwable)) ? null

            : predicate.test(cause) ? cause : findCause(cause);
         }
   }
(09.12.2016 at 09:27) trungdv trungdv's gravatar image
1

Continues...

 public class ConcurrencyErrorThrowablePredicate implements Predicate<Throwable> {   
     @Override
  public boolean test(Throwable exception) {

    return exception instanceof ConcurrencyModificationPersistenceException;
       }
}

//When using it Throwable ex = new CauseFinder(new ConcurrencyErrorThrowablePredicate()).findCause(error.getCause());

(09.12.2016 at 09:27) trungdv trungdv's gravatar image
error.getTechnicalCause()
link

answered 07.12.2016 at 13:22

Reguel%20Wermelinger's gravatar image

Reguel Werme... ♦♦
9.4k31958
accept rate: 70%

Thanks but actually it return ch.ivyteam.ivy.scripting.exceptions.runtime.IvyScriptRuntimeException. i also tried with all api i see but none of them return what i want

(08.12.2016 at 02:16) trungdv trungdv's gravatar image

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×8

Asked: 07.12.2016 at 12:05

Seen: 2,162 times

Last updated: 09.12.2016 at 09:37