Implements phantom.onError for error handlers