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.stream.DriverBufferedInputStream; 28 29 35 public class BackendDriverException extends SerializableException 36 { 37 private static final long serialVersionUID = -4044262679874226846L; 38 39 42 public BackendDriverException(DriverBufferedInputStream in) throws IOException 43 { 44 super(in); 45 } 46 47 59 public BackendDriverException(Throwable start) 60 { 61 super(start.getMessage(), convertNext(start)); convertStackTrace(start); 63 64 if (start instanceof SQLException ) { 66 SQLException sqlE = (SQLException ) start; 67 setSQLState(sqlE.getSQLState()); 68 setErrorCode(sqlE.getErrorCode()); 69 } 70 } 71 72 76 77 private static SerializableException convertNext(Throwable regularEx) 78 { 79 83 89 Throwable newStyleCause = regularEx.getCause(); 90 if (null != newStyleCause) 91 return new BackendDriverException(newStyleCause); 92 93 if (regularEx instanceof SQLException ) 95 { 96 SQLException nextE = ((SQLException ) regularEx).getNextException(); 97 if (null != nextE) 98 return new BackendDriverException(nextE); 99 } 100 101 return null; 103 104 } 105 } | Popular Tags |