Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: a358f852390f4f421de14e58d1c74c2e7d1a2a56 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*******************************************************************************
 * Copyright (c) 2008, 2010 Wind River Systems and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     Wind River Systems - initial API and implementation
 *******************************************************************************/
package org.eclipse.tcf.debug.test.util;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * Exception that combines several exceptions for propagation to client. 
 */
public class AggregateError extends Exception {
    private static final long serialVersionUID = 1L;
    
    final private List<Throwable> fChildren = Collections.synchronizedList(new ArrayList<Throwable>(1));
    
    public AggregateError(String message) {
        super(message);
    }
    
    public void add(Throwable child) {
        boolean initCause = false;
        synchronized(fChildren) {
            if (fChildren.isEmpty()) {
                initCause = true;
            }
            fChildren.add(child);
        }
        if (initCause) {
            super.initCause(child);
        }
    }
    
    public List<Throwable> getChildren() {
        return fChildren;
    }
}

Back to the top