001 /** 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 package javax.xml.bind; 018 019 import java.io.PrintStream; 020 021 public class TypeConstraintException extends RuntimeException { 022 023 private String errorCode; 024 private Throwable linkedException; 025 026 public TypeConstraintException(String message) { 027 this(message, null, null); 028 } 029 030 public TypeConstraintException(String message, String errorCode) { 031 this(message, errorCode, null); 032 } 033 034 public TypeConstraintException(String message, String errorCode, Throwable cause) { 035 super(message); 036 this.errorCode = errorCode; 037 this.linkedException = cause; 038 } 039 040 public TypeConstraintException(String message, Throwable cause) { 041 this(message, null, cause); 042 } 043 044 public TypeConstraintException(Throwable cause) { 045 this(null, null, cause); 046 } 047 048 public String getErrorCode() { 049 return errorCode; 050 } 051 052 public Throwable getLinkedException() { 053 return getCause(); 054 } 055 056 public synchronized void setLinkedException(Throwable linkedException) { 057 this.linkedException = linkedException; 058 } 059 060 public String toString() { 061 return linkedException != null ? 062 super.toString() + "\n - with linked exception:\n[" + linkedException.toString() + "]" : 063 super.toString(); 064 } 065 066 public void printStackTrace() { 067 super.printStackTrace(); 068 } 069 070 public void printStackTrace(PrintStream ps) { 071 super.printStackTrace(ps); 072 } 073 074 }