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 /** 035 * For multiple causes. 036 */ 037 private List<Throwable> causes; 038 039 040 /** 041 * Creates a new resolve exception. 042 * 043 * @param message The message. 044 */ 045 public ResolveException(final String message) { 046 super(message); 047 } 048 049 050 /** 051 * Creates a new resolve exception. 052 * 053 * @param message The message. 054 * @param cause The cause. 055 */ 056 public ResolveException(final String message, final Throwable cause) { 057 super(message, cause); 058 } 059 060 061 /** 062 * Creates a new resolve exception with potentially multiple causes. 063 * 064 * @param message The message. 065 * @param causes The causes, empty list or {@code null} if none. 066 */ 067 public ResolveException(final String message, final List<Throwable> causes) { 068 super(message); 069 this.causes = causes; 070 } 071 072 073 /** 074 * Creates a new resolve exception. 075 * 076 * @param message The message. 077 * @param errorObject The error object. 078 */ 079 public ResolveException(final String message, final ErrorObject errorObject) { 080 super(message, errorObject); 081 } 082 083 084 /** 085 * Returns the exception causes. 086 * 087 * @return The exception causes, empty list if none. 088 */ 089 public List<Throwable> getCauses() { 090 if (causes != null) { 091 return causes; 092 } else if (getCause() != null){ 093 return Collections.singletonList(getCause()); 094 } else { 095 return Collections.emptyList(); 096 } 097 } 098}