001/* 002 * oauth2-oidc-sdk 003 * 004 * Copyright 2012-2020, Connect2id Ltd and contributors. 005 * 006 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use 007 * this file except in compliance with the License. You may obtain a copy of the 008 * License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software distributed 013 * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 014 * CONDITIONS OF ANY KIND, either express or implied. See the License for the 015 * specific language governing permissions and limitations under the License. 016 */ 017 018package com.nimbusds.openid.connect.sdk.federation.trust; 019 020 021import java.util.Collections; 022import java.util.List; 023 024import com.nimbusds.oauth2.sdk.ErrorObject; 025import com.nimbusds.oauth2.sdk.GeneralException; 026 027 028/** 029 * Resolve exception. 030 */ 031public class ResolveException extends GeneralException { 032 033 034 private static final long serialVersionUID = 1039304462191728890L; 035 036 037 /** 038 * For multiple causes. 039 */ 040 private List<Throwable> causes; 041 042 043 /** 044 * Creates a new resolve exception. 045 * 046 * @param message The message. 047 */ 048 public ResolveException(final String message) { 049 super(message); 050 } 051 052 053 /** 054 * Creates a new resolve exception. 055 * 056 * @param message The message. 057 * @param cause The cause. 058 */ 059 public ResolveException(final String message, final Throwable cause) { 060 super(message, cause); 061 } 062 063 064 /** 065 * Creates a new resolve exception with potentially multiple causes. 066 * 067 * @param message The message. 068 * @param causes The causes, empty list or {@code null} if none. 069 */ 070 public ResolveException(final String message, final List<Throwable> causes) { 071 super(message); 072 this.causes = causes; 073 } 074 075 076 /** 077 * Creates a new resolve exception. 078 * 079 * @param message The message. 080 * @param errorObject The error object. 081 */ 082 public ResolveException(final String message, final ErrorObject errorObject) { 083 super(message, errorObject); 084 } 085 086 087 /** 088 * Returns the exception causes. 089 * 090 * @return The exception causes, empty list if none. 091 */ 092 public List<Throwable> getCauses() { 093 if (causes != null) { 094 return causes; 095 } else if (getCause() != null){ 096 return Collections.singletonList(getCause()); 097 } else { 098 return Collections.emptyList(); 099 } 100 } 101}