From 1a383aced5d8725c13d4ee31729b26a9105f9a93 Mon Sep 17 00:00:00 2001 From: Spencer Alger Date: Thu, 8 May 2014 17:12:20 -0700 Subject: [PATCH] added a new RequestTypeError class that connectionClasses can throw to prevent a request from being retried and respond directly to the user. --- src/lib/errors.js | 8 ++++++++ src/lib/transport.js | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/src/lib/errors.js b/src/lib/errors.js index d2f261548..728c1f64c 100644 --- a/src/lib/errors.js +++ b/src/lib/errors.js @@ -69,6 +69,14 @@ errors.Serialization = function Serialization(msg) { _.inherits(errors.Serialization, ErrorAbstract); +/** + * Thrown when a browser compatability issue is detected (cough, IE, cough) + */ +errors.RequestTypeError = function RequestTypeError(feature) { + ErrorAbstract.call(this, 'Cross-domain AJAX requests ' + feature + ' are not supported', errors.RequestTypeError); +}; +_.inherits(errors.RequestTypeError, ErrorAbstract); + var statusCodes = { /** diff --git a/src/lib/transport.js b/src/lib/transport.js index cd2fea89f..1e3f98954 100644 --- a/src/lib/transport.js +++ b/src/lib/transport.js @@ -180,6 +180,12 @@ Transport.prototype.request = function (params, cb) { requestAborter = void 0; + if (err instanceof errors.RequestTypeError) { + self.log.error('Connection refused to execute the request', err); + respond(err, body, status, headers); + return; + } + if (err) { connection.setStatus('dead'); if (remainingRetries) {