Skip to content

Commit

Permalink
#191 improve error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
teosarca committed Feb 27, 2017
1 parent e1a927a commit 90de886
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.concurrent.Callable;

import org.adempiere.ad.trx.api.ITrxManager;
import org.adempiere.exceptions.AdempiereException;
import org.adempiere.util.Services;
import org.adempiere.util.lang.IAutoCloseable;
import org.slf4j.Logger;
Expand Down Expand Up @@ -47,7 +48,7 @@ public static final Execution getCurrent()
final Execution execution = currentExecutionHolder.get();
if (execution == null)
{
throw new IllegalStateException("No current execution found for thread: " + Thread.currentThread().getName());
throw new AdempiereException("No current execution found for thread: " + Thread.currentThread().getName());
}
return execution;
}
Expand All @@ -57,7 +58,7 @@ private static Execution startExecution()
final Execution executionOld = currentExecutionHolder.get();
if (executionOld != null)
{
throw new IllegalStateException("Cannot start execution on thread '" + Thread.currentThread().getName() + "' because there is another execution currently running: " + executionOld);
throw new AdempiereException("Cannot start execution on thread '" + Thread.currentThread().getName() + "' because there is another execution currently running: " + executionOld);
}

final Execution execution = new Execution();
Expand Down Expand Up @@ -141,7 +142,7 @@ public synchronized void close()
final Execution executionNow = currentExecutionHolder.get();
if (this != executionNow)
{
throw new IllegalStateException("Cannot close the execution because current execution is not the one we expected."
throw new AdempiereException("Cannot close the execution because current execution is not the one we expected."
+ "\n Expected: " + this
+ "\n Current: " + executionNow
+ "\n Current thread: " + Thread.currentThread().getName()
Expand Down

0 comments on commit 90de886

Please sign in to comment.