Revision e0a0c6ea
b/src/gr/grnet/pithos/web/client/Pithos.java | ||
---|---|---|
79 | 79 |
*/ |
80 | 80 |
public class Pithos implements EntryPoint, ResizeHandler { |
81 | 81 |
|
82 |
private static final boolean IsLOGEnabled = true; |
|
83 |
|
|
82 | 84 |
public static final Configuration config = GWT.create(Configuration.class); |
83 | 85 |
|
84 | 86 |
public interface Style extends CssResource { |
... | ... | |
336 | 338 |
} |
337 | 339 |
}-*/; |
338 | 340 |
|
339 |
public static void LOG(Object ...args) { |
|
340 |
if(false) { |
|
341 |
final StringBuilder sb = new StringBuilder(); |
|
342 |
for(Object arg : args) { |
|
343 |
if(arg instanceof Throwable) { |
|
344 |
final Throwable error = (Throwable) arg; |
|
345 |
sb.append("\nException: [" + error.toString().replace("\n", "\n ") + "]"); |
|
346 |
Throwable cause = error.getCause(); |
|
347 |
if(cause != null) { |
|
348 |
sb.append("\nCauses:\n"); |
|
349 |
while(cause != null) { |
|
350 |
sb.append(" "); |
|
351 |
sb.append("[" + cause.toString().replace("\n", "\n ") + "]"); |
|
352 |
sb.append("\n"); |
|
353 |
cause = cause.getCause(); |
|
354 |
} |
|
355 |
} |
|
356 |
else { |
|
357 |
sb.append("\n"); |
|
358 |
} |
|
359 |
|
|
360 |
StackTraceElement[] stackTrace = error.getStackTrace(); |
|
361 |
sb.append("Stack trace (" + stackTrace.length + " elements):\n"); |
|
362 |
for(int i = 0; i < stackTrace.length; i++) { |
|
363 |
StackTraceElement errorElem = stackTrace[i]; |
|
364 |
sb.append(" [" + i + "] "); |
|
365 |
sb.append(errorElem.toString()); |
|
366 |
sb.append("\n"); |
|
367 |
} |
|
368 |
} |
|
369 |
else { |
|
370 |
sb.append(arg); |
|
371 |
} |
|
341 |
public static void LOGError(Throwable error, StringBuilder sb) { |
|
342 |
if(!IsLOGEnabled) { return; } |
|
343 |
|
|
344 |
sb.append("\nException: [" + error.toString().replace("\n", "\n ") + "]"); |
|
345 |
Throwable cause = error.getCause(); |
|
346 |
if(cause != null) { |
|
347 |
sb.append("\nCauses:\n"); |
|
348 |
while(cause != null) { |
|
349 |
sb.append(" "); |
|
350 |
sb.append("[" + cause.toString().replace("\n", "\n ") + "]"); |
|
351 |
sb.append("\n"); |
|
352 |
cause = cause.getCause(); |
|
372 | 353 |
} |
354 |
} |
|
355 |
else { |
|
356 |
sb.append("\n"); |
|
357 |
} |
|
358 |
|
|
359 |
StackTraceElement[] stackTrace = error.getStackTrace(); |
|
360 |
sb.append("Stack trace (" + stackTrace.length + " elements):\n"); |
|
361 |
for(int i = 0; i < stackTrace.length; i++) { |
|
362 |
StackTraceElement errorElem = stackTrace[i]; |
|
363 |
sb.append(" [" + i + "] "); |
|
364 |
sb.append(errorElem.toString()); |
|
365 |
sb.append("\n"); |
|
366 |
} |
|
367 |
} |
|
368 |
|
|
369 |
public static void LOGError(Throwable error) { |
|
370 |
if(!IsLOGEnabled) { return; } |
|
371 |
|
|
372 |
final StringBuilder sb = new StringBuilder(); |
|
373 |
LOGError(error, sb); |
|
374 |
if(sb.length() > 0) { |
|
375 |
__ConsoleLog(sb.toString()); |
|
376 |
} |
|
377 |
} |
|
373 | 378 |
|
379 |
public static boolean isLogEnabled() { |
|
380 |
return IsLOGEnabled; |
|
381 |
} |
|
374 | 382 |
|
375 |
if(sb.length() > 0) { |
|
376 |
__ConsoleLog(sb.toString()); |
|
383 |
public static void LOG(Object ...args) { |
|
384 |
if(!IsLOGEnabled) { return; } |
|
385 |
|
|
386 |
final StringBuilder sb = new StringBuilder(); |
|
387 |
for(Object arg : args) { |
|
388 |
if(arg instanceof Throwable) { |
|
389 |
LOGError((Throwable) arg, sb); |
|
377 | 390 |
} |
391 |
else { |
|
392 |
sb.append(arg); |
|
393 |
} |
|
394 |
} |
|
395 |
|
|
396 |
if(sb.length() > 0) { |
|
397 |
__ConsoleLog(sb.toString()); |
|
378 | 398 |
} |
379 | 399 |
} |
380 | 400 |
|
... | ... | |
1312 | 1332 |
|
1313 | 1333 |
public void setError(Throwable t) { |
1314 | 1334 |
error = t; |
1335 |
LOG(t); |
|
1315 | 1336 |
} |
1316 | 1337 |
|
1317 | 1338 |
public void showRelevantToolbarButtons() { |
... | ... | |
1364 | 1385 |
|
1365 | 1386 |
@Override |
1366 | 1387 |
public void onError(Throwable _t) { |
1367 |
LOG(_t); |
|
1368 | 1388 |
setError(_t); |
1369 | 1389 |
if(_t instanceof RestException) { |
1370 | 1390 |
displayError("Unable to create folder: " + ((RestException) _t).getHttpStatusText()); |
Also available in: Unified diff