<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Answers to: How to get root cause of BpmException</title><link>https://answers.axonivy.com/questions/2249/how-to-get-root-cause-of-bpmexception</link><description>&lt;p&gt;Hi all&lt;/p&gt;
&lt;p&gt;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:
&lt;img alt="alt text" src="http://answers.axonivy.com/upfiles/Untitled_nUduUtM.png"&gt;&lt;/p&gt;
&lt;p&gt;The read box is the root cause actually that i want to get it out.&lt;/p&gt;
&lt;p&gt;Is there any way?&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;</description><atom:link href="https://answers.axonivy.com/questions/2249/how-to-get-root-cause-of-bpmexception" rel="self"></atom:link><language>en</language><lastBuildDate>Fri, 09 Dec 2016 09:27:23 -0500</lastBuildDate><item><title>Comment by trungdv on Flavio Sadeghi's answer</title><link>https://answers.axonivy.com/questions/2249/how-to-get-root-cause-of-bpmexception#2266</link><description>&lt;p&gt;Continues...&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; public class ConcurrencyErrorThrowablePredicate implements Predicate&amp;lt;Throwable&amp;gt; {   
     @Override
  public boolean test(Throwable exception) {

    return exception instanceof ConcurrencyModificationPersistenceException;
       }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;//When using it
Throwable ex =  new CauseFinder(new 
ConcurrencyErrorThrowablePredicate()).findCause(error.getCause());&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">trungdv</dc:creator><pubDate>Fri, 09 Dec 2016 09:27:23 -0500</pubDate><guid>https://answers.axonivy.com/questions/2249/how-to-get-root-cause-of-bpmexception#2266</guid></item><item><title>Comment by trungdv on Flavio Sadeghi's answer</title><link>https://answers.axonivy.com/questions/2249/how-to-get-root-cause-of-bpmexception#2265</link><description>&lt;p&gt;yes, i came up with the similar solution:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;   public class CauseFinder {
            private Predicate&amp;lt;Throwable&amp;gt; predicate;

        public CauseFinder(Predicate&amp;lt;Throwable&amp;gt; predicate) {

                       this.predicate = predicate;

          }
         public Throwable findCause(Throwable throwable) {

               Throwable cause = throwable.getCause();

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

            : predicate.test(cause) ? cause : findCause(cause);
         }
   }
&lt;/code&gt;&lt;/pre&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">trungdv</dc:creator><pubDate>Fri, 09 Dec 2016 09:27:15 -0500</pubDate><guid>https://answers.axonivy.com/questions/2249/how-to-get-root-cause-of-bpmexception#2265</guid></item><item><title>Answer by Flavio Sadeghi</title><link>https://answers.axonivy.com/questions/2249/how-to-get-root-cause-of-bpmexception/2260</link><description>&lt;p&gt;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...&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;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;
    }
}
&lt;/code&gt;&lt;/pre&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Flavio Sadeghi</dc:creator><pubDate>Thu, 08 Dec 2016 14:49:25 -0500</pubDate><guid>https://answers.axonivy.com/questions/2249/how-to-get-root-cause-of-bpmexception/2260</guid></item><item><title>Comment by trungdv on Reguel Wermelinger's answer</title><link>https://answers.axonivy.com/questions/2249/how-to-get-root-cause-of-bpmexception#2255</link><description>&lt;p&gt;Thanks but actually it return &lt;em&gt;ch.ivyteam.ivy.scripting.exceptions.runtime.IvyScriptRuntimeException&lt;/em&gt;. i also tried with all api i see but none of them return what i want&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">trungdv</dc:creator><pubDate>Thu, 08 Dec 2016 02:16:15 -0500</pubDate><guid>https://answers.axonivy.com/questions/2249/how-to-get-root-cause-of-bpmexception#2255</guid></item><item><title>Answer by Reguel Wermelinger</title><link>https://answers.axonivy.com/questions/2249/how-to-get-root-cause-of-bpmexception/2250</link><description>&lt;pre&gt;&lt;code&gt;error.getTechnicalCause()
&lt;/code&gt;&lt;/pre&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Reguel Wermelinger</dc:creator><pubDate>Wed, 07 Dec 2016 13:22:08 -0500</pubDate><guid>https://answers.axonivy.com/questions/2249/how-to-get-root-cause-of-bpmexception/2250</guid></item></channel></rss>