protected String[] getMessagesKeys(Throwable throwable, String keySuffix) { if (messagesKey != null) { return new String[] {messagesKey}; } List<String> messageKeyList = new ArrayList<String>(); Class clazz = throwable.getClass(); if (throwable instanceof ErrorCoded) { messageKeyList.add(((ErrorCoded) throwable).getErrorCode() + keySuffix); } if (throwable instanceof SQLException) { messageKeyList.add(SQLException.class.getName() + "." + ((SQLException) throwable).getErrorCode() + keySuffix); } while (clazz != Object.class) { messageKeyList.add(clazz.getName() + keySuffix); clazz = clazz.getSuperclass(); } return messageKeyList.toArray(new String[messageKeyList.size()]); }
protected String extractErrorCode(Throwable throwable) { if (throwable instanceof ErrorCoded) { return ((ErrorCoded) throwable).getErrorCode(); } else if (throwable instanceof SQLException) { return Integer.toString(((SQLException) throwable).getErrorCode()); } else { return null; } }