3 TrakEM2 plugin for ImageJ(C).
4 Copyright (C) 2005, 2006 Albert Cardona and Rodney Douglas.
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation (http://www.gnu.org/licenses/gpl.txt )
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 You may contact Albert Cardona at acardona at ini.phys.ethz.ch
20 Institute of Neuroinformatics, University of Zurich / ETH, Switzerland.
23 package ini
.trakem2
.utils
;
27 import java
.io
.CharArrayWriter
;
28 import java
.io
.PrintWriter
;
30 /** A class to easily show the stack trace of an error in different operating systems.
33 public class IJError
{
35 static public final void print(final Throwable e
) {
38 static public final void print(final Throwable e
, final boolean stdout
) {
40 CharArrayWriter caw
= new CharArrayWriter();
41 PrintWriter pw
= new PrintWriter(caw
);
42 e
.printStackTrace(pw
);
43 String s
= caw
.toString();
45 if (s
.indexOf("ThreadDeath")>0)
47 else s
= fixNewLines(s
);
49 String msg
= "==================\nERROR:\n" + s
+ "\n======================";
50 if (stdout
) Utils
.log2(msg
);
54 /** Converts carriage returns to line feeds. Copied from ij.util.tools by Wayne Rasband*/
56 static final String
fixNewLines(final String s
) {
57 final char[] chars
= s
.toCharArray();
58 for (int i
=0; i
<chars
.length
; i
++) {
59 if (chars
[i
]=='\r') chars
[i
] = '\n';
61 return new String(chars
);
65 static boolean isWin
, isMac
;
68 osname
= System
.getProperty("os.name");
69 isWin
= osname
.startsWith("Windows");
70 isMac
= !isWin
&& osname
.startsWith("Mac");
73 static boolean isMacintosh() {