1 24 package org.ofbiz.base.util; 25 26 import java.io.PrintStream ; 27 import java.io.PrintWriter ; 28 import java.util.List ; 29 30 37 public class GeneralException extends Exception { 38 39 Throwable nested = null; 40 List messages = null; 41 42 45 public GeneralException() { 46 super(); 47 } 48 49 53 public GeneralException(String msg) { 54 super(msg); 55 } 56 57 62 public GeneralException(String msg, Throwable nested) { 63 super(msg); 64 this.nested = nested; 65 } 66 67 71 public GeneralException(Throwable nested) { 72 super(); 73 this.nested = nested; 74 } 75 76 81 public GeneralException(String msg, List messages) { 82 super(msg); 83 this.messages = messages; 84 } 85 86 92 public GeneralException(String msg, List messages, Throwable nested) { 93 super(msg); 94 this.nested = nested; 95 this.messages = messages; 96 } 97 98 103 public GeneralException(List messages, Throwable nested) { 104 super(); 105 this.nested = nested; 106 this.messages = messages; 107 } 108 109 public GeneralException(List messages) { 110 super(); 111 this.messages = messages; 112 } 113 114 115 public String getMessage() { 116 if (nested != null) { 117 if (super.getMessage() == null) { 118 return nested.getMessage(); 119 } else { 120 return super.getMessage() + " (" + nested.getMessage() + ")"; 121 } 122 } else { 123 return super.getMessage(); 124 } 125 } 126 127 public List getMessageList() { 128 return this.messages; 129 } 130 131 132 public String getNonNestedMessage() { 133 return super.getMessage(); 134 } 135 136 137 public Throwable getNested() { 138 if (nested == null) { 139 return this; 140 } 141 return nested; 142 } 143 144 145 public void printStackTrace() { 146 super.printStackTrace(); 147 if (nested != null) nested.printStackTrace(); 148 } 149 150 151 public void printStackTrace(PrintStream ps) { 152 super.printStackTrace(ps); 153 if (nested != null) nested.printStackTrace(ps); 154 } 155 156 157 public void printStackTrace(PrintWriter pw) { 158 super.printStackTrace(pw); 159 if (nested != null) nested.printStackTrace(pw); 160 } 161 } 162 163 | Popular Tags |