001package com.identityworksllc.iiq.common; 002 003import sailpoint.tools.GeneralException; 004 005import java.io.PrintStream; 006import java.io.PrintWriter; 007 008/** 009 * This exception is to be used whenever an exception is caught inside of a catch 010 * block. It will display details of both exceptions on printStackTrace and other 011 * methods. 012 * 013 * This particular version extends GeneralException in order to allow throwing 014 * via Sailpoint's API. All methods are delegated to an internal {@link PairedException}. 015 */ 016public class PairedGeneralException extends GeneralException { 017 /** 018 * The delegated exception 019 */ 020 private final PairedException exception; 021 022 /** 023 * Constructs a new PairedException from the two throwables 024 * @param t1 The first throwable 025 * @param t2 The second throwable 026 */ 027 public PairedGeneralException(Throwable t1, Throwable t2) { 028 exception = new PairedException(t1, t2); 029 } 030 031 public PairedGeneralException(String message, Throwable t1, Throwable t2) { 032 exception = new PairedException(message, t1, t2); 033 } 034 035 @Override 036 public Throwable fillInStackTrace() { 037 return exception.fillInStackTrace(); 038 } 039 040 @Override 041 public Throwable getCause() { 042 return exception.getCause(); 043 } 044 045 @Override 046 public String getLocalizedMessage() { 047 return exception.getLocalizedMessage(); 048 } 049 050 @Override 051 public String getMessage() { 052 return exception.getMessage(); 053 } 054 055 /** 056 * Gets the parent of the second exception 057 * @return The stack trace for the second exception, via {@link PairedException#getSecondCause()} ()} 058 */ 059 public Throwable getSecondCause() { 060 return exception.getSecondCause(); 061 } 062 063 /** 064 * Gets the second stack trace 065 * @return The stack trace for the second exception, via {@link PairedException#getSecondStackTrace()} 066 */ 067 public StackTraceElement[] getSecondStackTrace() { 068 return exception.getSecondStackTrace(); 069 } 070 071 @Override 072 public StackTraceElement[] getStackTrace() { 073 return exception.getStackTrace(); 074 } 075 076 @Override 077 public Throwable initCause(Throwable cause) { 078 return exception.initCause(cause); 079 } 080 081 @Override 082 public void printStackTrace(PrintWriter s) { 083 exception.printStackTrace(s); 084 } 085 086 @Override 087 public void printStackTrace() { 088 exception.printStackTrace(); 089 } 090 091 @Override 092 public void printStackTrace(PrintStream s) { 093 exception.printStackTrace(s); 094 } 095 096 @Override 097 public void setStackTrace(StackTraceElement[] stackTrace) { 098 exception.setStackTrace(stackTrace); 099 } 100 101 @Override 102 public String toString() { 103 return exception.toString(); 104 } 105}