1 21 22 package org.continuent.sequoia.common.exceptions.driver.protocol; 23 24 import java.io.IOException ; 25 import java.sql.SQLException ; 26 27 import org.continuent.sequoia.common.exceptions.NoMoreBackendException; 28 import org.continuent.sequoia.common.exceptions.NoMoreControllerException; 29 import org.continuent.sequoia.common.exceptions.NotImplementedException; 30 import org.continuent.sequoia.common.stream.DriverBufferedInputStream; 31 32 39 public class ControllerCoreException extends SerializableException 40 { 41 private static final long serialVersionUID = -4526646797888340909L; 42 43 private static final int UNKNOWN = 0; 44 private static final int NO_MORE_BACKEND = 1; 45 private static final int NO_MORE_CONTROLLER = 2; 46 private static final int NOT_IMPLEMENTED = 3; 47 48 private static int exceptionTypeCode(Throwable ex) 49 { 50 if (ex instanceof NoMoreBackendException) 51 return NO_MORE_BACKEND; 52 if (ex instanceof NoMoreControllerException) 53 return NO_MORE_CONTROLLER; 54 if (ex instanceof NotImplementedException) 55 return NOT_IMPLEMENTED; 56 57 return UNKNOWN; 58 } 59 60 69 public Exception compatibilityWrapperHack() 70 { 71 Exception wrapper; 72 switch (this.getErrorCode()) 73 { 74 case NO_MORE_BACKEND : 75 wrapper = new NoMoreBackendException(getMessage(), getSQLState(), 76 getErrorCode()); 77 break; 78 case NO_MORE_CONTROLLER : 79 wrapper = new NoMoreControllerException(getMessage(), getSQLState(), 80 getErrorCode()); 81 break; 82 case NOT_IMPLEMENTED : 83 wrapper = new NotImplementedException(getMessage(), getSQLState(), 84 getErrorCode()); 85 break; 86 default : wrapper = new SQLException (getMessage(), getSQLState(), getErrorCode()); 88 } 89 wrapper.initCause(this); 90 return wrapper; 91 } 92 93 96 public ControllerCoreException(DriverBufferedInputStream in) throws IOException 97 { 98 super(in); 99 } 100 101 109 public ControllerCoreException(Throwable ex) 110 { 111 super(ex); 112 113 116 setErrorCode(exceptionTypeCode(ex)); 118 119 } 120 121 } 122 | Popular Tags |