001// Copyright (c) 2001 Hursh Jain (http://www.mollypages.org) 002// The Molly framework is freely distributable under the terms of an 003// MIT-style license. For details, see the molly pages web site at: 004// http://www.mollypages.org/. Use, modify, have fun ! 005 006package fc.util; 007 008import java.util.*; 009 010/** 011Handles argument {@link Argcheck} errors by printing the thread, time and stack trace 012to <code>System.err</code>. <code>System.err</code> is chosen because the 013default assertion mechanism also writes a message to that location. 014After writing the message to <code>System.err</code>, a new 015<code>IllegalArgumentException</code> is thrown. 016 017Date: 5/30/2002 018@author hursh jain 019@version 1.0 020**/ 021public class BasicArgcheckFailHandler implements IArgcheckFailHandler 022{ 023long id = 0; 024 025public void handle(String msg) { 026 long myid = 0; 027 synchronized (this){ 028 myid = id++; 029 } 030 String argcheckmsg = Thread.currentThread() + " Argcheck error [#" + myid + "] " + ((msg!=null) ? msg : ""); 031 RuntimeException e = new IllegalArgumentException(argcheckmsg); 032 e.printStackTrace(System.err); 033 throw e; 034 } 035}