Subscribe to RSS

Some rights reserved

Except where otherwise noted, content on this site is licensed under a Creative Commons License


programming‎ > ‎java‎ > ‎

carp

For programmers who are Perl/Java bilingual: carp in java:

public class CarpTest {

   public static void main(String[] args) {
     new CarpTest().run();
   }

   public void run() {
     methodThatCarps();
   }

   private void methodThatCarps() {
     carp("Message");
   }

   private void carp(String message) {
     RuntimeException e = new RuntimeException(message);
     e.fillInStackTrace();
     StackTraceElement[] stack = e.getStackTrace();
     e.setStackTrace(Arrays.copyOfRange(stack, 0, stack.length - 1));
     throw e;
   }
}

code like this represent the Carp!