Refactored error handling code to remove redundant method/enum.