1 16 package scriptella.core; 17 18 import scriptella.configuration.Location; 19 20 21 28 public class ExceptionInterceptor extends ElementInterceptor { 29 private Location location; 30 31 public ExceptionInterceptor(ExecutableElement next, Location location) { 32 super(next); 33 this.location = location; 34 } 35 36 public void execute(final DynamicContext ctx) { 37 try { 38 EtlCancelledException.checkEtlCancelled(); 39 executeNext(ctx); 40 } catch (ExecutionException e) { 41 throw e; 43 } catch (Exception e) { 44 throw new ExecutionException(e, location); 45 } 46 } 47 48 public static ExecutableElement prepare( 49 final ExecutableElement next, final Location loc) { 50 return new ExceptionInterceptor(next, loc); 51 } 52 53 public static class ExecutionException extends SystemException { 54 private Location location; 55 56 public ExecutionException(Throwable cause, Location location) { 57 this(location + " failed: " + cause.getMessage(), cause, location); 58 } 59 60 public ExecutionException(String message, Throwable cause, 61 Location location) { 62 super(message, cause); 63 this.location = location; 64 } 65 66 69 public Location getLocation() { 70 return location; 71 } 72 } 73 } 74 | Popular Tags |