]> git.basschouten.com Git - openhab-addons.git/blob
860917e2ba64a437d27e44216a2ec949da18c1ee
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License 2.0 which is available at
9  * http://www.eclipse.org/legal/epl-2.0
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.ecobee.internal.util;
14
15 import java.util.ArrayList;
16 import java.util.List;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19
20 /**
21  * The {@link ExceptionUtils} class defines static Exception related methods
22  *
23  * @author Leo Siepel - Initial contribution
24  */
25 @NonNullByDefault
26 public class ExceptionUtils {
27
28     public static Throwable getRootThrowable(Throwable throwable) {
29         List<Throwable> list = new ArrayList<>();
30         while (!list.contains(throwable)) {
31             list.add(throwable);
32             Throwable throwableLocal = throwable.getCause();
33             if (throwableLocal != null) {
34                 throwable = throwableLocal;
35             }
36         }
37         return throwable;
38     }
39 }