Handles error response