Add handle_error method