Better handling of number format exception in android
问题 I've got the following code snippet that I'm thinking of refactoring to a more abstract application exception handler but I want to make sure I've got it as tidy as possible first Any suggestions on how to improve this code or make it more resuable int id = -1; final StringBuilder errorMessage = new StringBuilder("Bad Input Value: "); try { id = Integer.parseInt(edtId.getText().toString()); } catch (final NumberFormatException e) { errorMessage.append("Failed to parse id " + e.getMessage());