1 20 package org.apache.derby.shared.common.error; 21 22 import org.apache.derby.shared.common.error.ExceptionSeverity; 23 24 27 public class ExceptionUtil 28 { 29 37 public static String getSQLStateFromIdentifier(String messageID) { 38 39 if (messageID.length() == 5) 40 return messageID; 41 return messageID.substring(0, 5); 42 } 43 44 47 public static int getSeverityFromIdentifier(String messageID) { 48 49 int lseverity = ExceptionSeverity.NO_APPLICABLE_SEVERITY; 50 51 switch (messageID.length()) { 52 case 5: 53 switch (messageID.charAt(0)) { 54 case '0': 55 switch (messageID.charAt(1)) { 56 case '1': 57 lseverity = ExceptionSeverity.WARNING_SEVERITY; 58 break; 59 case 'A': 60 case '7': 61 lseverity = ExceptionSeverity.STATEMENT_SEVERITY; 62 break; 63 case '8': 64 lseverity = ExceptionSeverity.SESSION_SEVERITY; 65 break; 66 } 67 break; 68 case '2': 69 case '3': 70 lseverity = ExceptionSeverity.STATEMENT_SEVERITY; 71 break; 72 case '4': 73 switch (messageID.charAt(1)) { 74 case '0': 75 lseverity = ExceptionSeverity.TRANSACTION_SEVERITY; 76 break; 77 case '2': 78 lseverity = ExceptionSeverity.STATEMENT_SEVERITY; 79 break; 80 } 81 break; 82 } 83 break; 84 85 default: 86 switch (messageID.charAt(6)) { 87 case 'M': 88 lseverity = ExceptionSeverity.SYSTEM_SEVERITY; 89 break; 90 case 'D': 91 lseverity = ExceptionSeverity.DATABASE_SEVERITY; 92 break; 93 case 'C': 94 lseverity = ExceptionSeverity.SESSION_SEVERITY; 95 break; 96 case 'T': 97 lseverity = ExceptionSeverity.TRANSACTION_SEVERITY; 98 break; 99 case 'S': 100 lseverity = ExceptionSeverity.STATEMENT_SEVERITY; 101 break; 102 case 'U': 103 lseverity = ExceptionSeverity.NO_APPLICABLE_SEVERITY; 104 break; 105 } 106 break; 107 } 108 109 return lseverity; 110 } 111 112 } 113 | Popular Tags |