Project

General

Profile

« Previous | Next » 

Revision e138e599

Added by Cherian Mathew almost 9 years ago

MANIFEST.MF : added apache commons exception package for use in messaging utils
MessagingUtils : updated to add all causes in the child statuses

View differences:

eu.etaxonomy.taxeditor.cdmlib/META-INF/MANIFEST.MF
195 195
 org.apache.commons.collections;uses:="org.apache.commons.collections.keyvalue,new org.apache.commons.collections",
196 196
 org.apache.commons.io;uses:="org.apache.commons.io.filefilter",
197 197
 org.apache.commons.lang;uses:="org.apache.commons.lang.exception",
198
 org.apache.commons.lang.exception,
198 199
 org.apache.fop.apps,
199 200
 org.apache.http,
200 201
 org.apache.http.client,
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/MessagingUtils.java
5 5
import java.util.ArrayList;
6 6
import java.util.List;
7 7

  
8
import org.apache.commons.lang.exception.ExceptionUtils;
8 9
import org.apache.log4j.Logger;
9 10
import org.eclipse.core.runtime.IStatus;
10 11
import org.eclipse.core.runtime.MultiStatus;
......
293 294
            throwable = getDefaultThrowable();
294 295
        }
295 296

  
296
        // add main execption
297
        for (StackTraceElement ste : throwable.getStackTrace()) {
298
            childStatuses.add(new Status(IStatus.ERROR, pluginId, "at " + ste.toString()));
299
        }
297
        int thCount = 0;
298
        int maxTraces = 4;
300 299

  
301
        // add cause
302
        if(throwable.getCause() != null) {
303
            childStatuses.add(new Status(IStatus.ERROR, pluginId, ""));
304
            childStatuses.add(new Status(IStatus.ERROR, pluginId, "Caused by : " + throwable.getCause().toString()));
305
            for (StackTraceElement ste : throwable.getCause().getStackTrace()) {
306
                // build & add status
307
                childStatuses.add(new Status(IStatus.ERROR, pluginId, "at " + ste.toString()));
300
        for(Throwable th : ExceptionUtils.getThrowables(throwable)) {
301
            // add main exception
302
            if(thCount == 0) {
303
                for (StackTraceElement ste : th.getStackTrace()) {
304
                    childStatuses.add(new Status(IStatus.ERROR, pluginId, "  at " + ste.toString()));
305
                }
306
            } else {
307
                // add recursive causes
308
                if(th != null) {
309
                    childStatuses.add(new Status(IStatus.ERROR, pluginId, ""));
310
                    String msg = th.toString();
311
                    childStatuses.add(new Status(IStatus.ERROR, pluginId, "Caused by : " + msg));
312
                    int traceCount = 0;
313
                    for (StackTraceElement ste : th.getStackTrace()) {
314
                        // add only pre-defined number of trace elements
315
                        if(traceCount > maxTraces) {
316
                            childStatuses.add(new Status(IStatus.ERROR, pluginId, "  ...."));
317
                            break;
318
                        }
319
                        // build & add status
320
                        childStatuses.add(new Status(IStatus.ERROR, pluginId, "  at " + ste.toString()));
321
                        traceCount++;
322
                    }
323
                }
308 324
            }
325
            thCount++;
309 326
        }
310

  
311 327
        String finalMessage = message;
312 328

  
313 329
        if(finalMessage == null || finalMessage.isEmpty()) {

Also available in: Unified diff