1 23 24 package org.objectweb.cjdbc.common.exceptions.driver.protocol; 25 26 import java.io.IOException ; 27 import java.sql.SQLException ; 28 29 import org.objectweb.cjdbc.common.exceptions.NoMoreBackendException; 30 import org.objectweb.cjdbc.common.exceptions.NoMoreControllerException; 31 import org.objectweb.cjdbc.common.exceptions.NotImplementedException; 32 import org.objectweb.cjdbc.common.stream.CJDBCInputStream; 33 34 41 public class ControllerCoreException 42 extends SerializableException 43 { 44 45 private static final int UNKNOWN = 0; 46 private static final int NO_MORE_BACKEND = 1; 47 private static final int NO_MORE_CONTROLLER = 2; 48 private static final int NOT_IMPLEMENTED = 3; 49 50 private static int exceptionTypeCode(Throwable ex) 51 { 52 if (ex instanceof NoMoreBackendException) 53 return NO_MORE_BACKEND; 54 if (ex instanceof NoMoreControllerException) 55 return NO_MORE_CONTROLLER; 56 if (ex instanceof NotImplementedException) 57 return NOT_IMPLEMENTED; 58 59 return UNKNOWN; 60 } 61 62 71 public Exception compatibilityWrapperHack() 72 { 73 Exception wrapper; 74 switch (this.getErrorCode()) 75 { 76 case NO_MORE_BACKEND : 77 wrapper = new NoMoreBackendException(getMessage(), getSQLState(), 78 getErrorCode()); 79 break; 80 case NO_MORE_CONTROLLER : 81 wrapper = new NoMoreControllerException(getMessage(), getSQLState(), 82 getErrorCode()); 83 break; 84 case NOT_IMPLEMENTED : 85 wrapper = new NotImplementedException(getMessage(), getSQLState(), 86 getErrorCode()); 87 break; 88 default : wrapper = new SQLException (getMessage(), getSQLState(), getErrorCode()); 90 } 91 wrapper.initCause(this); 92 return wrapper; 93 } 94 95 98 public ControllerCoreException(CJDBCInputStream in) throws IOException 99 { 100 super(in); 101 } 102 103 111 public ControllerCoreException(Throwable ex) 112 { 113 super(ex); 114 115 118 setErrorCode(exceptionTypeCode(ex)); 120 121 } 122 123 } 124 | Popular Tags |