1 16 package nl.hippo.asserts; 17 18 class Asserts 19 { 20 21 private static final int STACK_TRACE_ELEMENTS_OVERHEAD_SIZE = 3; 22 23 Asserts() 24 { 25 super(); 26 } 27 28 static RuntimeException createException(ExceptionFactory exceptionFactory, String message) 29 { 30 RuntimeException exception = exceptionFactory.createException(message); 31 StackTraceElement [] stackTrace = exception.getStackTrace(); 32 if (stackTrace != null && stackTrace.length >= STACK_TRACE_ELEMENTS_OVERHEAD_SIZE) 33 { 34 StackTraceElement [] newStackTrace = new StackTraceElement [stackTrace.length - STACK_TRACE_ELEMENTS_OVERHEAD_SIZE]; 35 System.arraycopy(stackTrace, STACK_TRACE_ELEMENTS_OVERHEAD_SIZE, newStackTrace, 0, newStackTrace.length); 36 exception.setStackTrace(newStackTrace); 37 } 38 return exception; 39 } 40 41 } 42 | Popular Tags |