1 package com.intendico.gorite;
4 * This is a specialozed {@link Error} that used for wrapping
5 * exceptions in a gorite intention chain, so as to give better
6 * guidance about where in the source execution the error occurs.
8 public class GoriteError extends Error {
13 public GoriteError(Goal.Instance instance,Throwable cause) {
14 super( "Uncaught Throwable" );
15 if ( cause instanceof GoriteError ) {
16 cause = cause.getCause();
19 // Reduce the stack trace for the cause in a good way...
20 StackTraceElement [] stack = getStackTrace();
21 StackTraceElement [] inner = cause.getStackTrace();
23 int at = inner.length - stack.length;
24 StackTraceElement created = instance.getGoal().created;
25 inner[ at ] = new StackTraceElement(
26 created.getClassName(),
27 created.getMethodName() +
28 "|" + instance.getGoal().getGoalName() + "|" + instance.head,
29 created.getFileName(),
30 created.getLineNumber() );
31 cause.setStackTrace( inner );