Internal callback method, will call the success callback specified
 in initialize or the failure callback if the html return status is
 300 or higher.
509119
def requestLoaded
      begin
        status = Native(`#{@xhr}.status`)
        raise if status >= 300
        json = JSON.parse(`#{@xhr}.response`)
        @callback.call(json)
      rescue => error
        @failed = true
        @error_callback.call(status, error)
      end

      destroy
    end
260054
function ajaxCallback(data, textStatus) {
            //responses should be a list of successful responses
            //if any request failed it *may or may not* be an http-level error
            //depending on server-side implementation
           // konsole.log("datarequest", data, textStatus, 'dbdata.'+txnId, comment);
            if (textStatus == 'success') {
                data.getErrors = function() {
                  if (this.error) return [this.error];
                  var errors = [];
                  for (var i=0; i < this.length; i++) {
                    if (this[i].error)
                      errors.push(this[i].error);
                  }
                  return errors;
                };
                data.hasErrors = function() { return this.getErrors().length > 0;}
                if (false !== $(elem).triggerHandler('dbdata-'+txnId, [data, request, comment])) {
                  $(elem).trigger('dbdata', [data, request, comment]);
                }
            } else {
                //when textStatus != 'success', data param will be a XMLHttpRequest obj
                var errorObj = {"jsonrpc": "2.0", "id": null,
                  "error": {"code": -32000,
                        "message": data.statusText || textStatus,
                        'data' : data.responseText
                  },
                  hasErrors: function() { return true;},
                  getErrors: function() { return [this.error];}
                };
                if (false !== $(elem).triggerHandler('dbdata-'+txnId, [errorObj, request, comment])) {
                  $(elem).trigger('dbdata', [errorObj, request, comment]);
                }
            }
         }
599002
function callback(ctx, err, result) {
    if (typeof ctx.custom === 'function') {
      var cust = function () {
        // Bind the callback to itself, so the resolve and reject
        // properties that we bound are available to the callback.
        // Then we push it onto the end of the arguments array.
        return ctx.custom.apply(cust, arguments);
      };
      cust.resolve = ctx.resolve;
      cust.reject = ctx.reject;
      cust.call(null, err, result);
    } else {
      if (err) {
        return ctx.reject(err);
      }
      ctx.resolve(result);
    }
  }
1051256
def raise_error_if_failed!(result)
      return if result.status.statusCode == 0
      error_message = result.status.errorMessage || 'Execution failed!'
      raise RBHive::TCLIConnectionError.new(error_message)
    end
1151356
function (success, error) {
            //run source if it function
            var source;
            if ($.isFunction(this.options.source)) {
                source = this.options.source.call(this.options.scope);
                this.sourceData = null;
                //note: if function returns the same source as URL - sourceData will be taken from cahce and no extra request performed
            } else {
                source = this.options.source;
            }            
            
            //if allready loaded just call success
            if(this.options.sourceCache && $.isArray(this.sourceData)) {
                success.call(this);
                return; 
            }

            //try parse json in single quotes (for double quotes jquery does automatically)
            try {
                source = $.fn.editableutils.tryParseJson(source, false);
            } catch (e) {
                error.call(this);
                return;
            }

            //loading from url
            if (typeof source === 'string') {
                //try to get sourceData from cache
                if(this.options.sourceCache) {
                    var cacheID = source,
                    cache;

                    if (!$(document).data(cacheID)) {
                        $(document).data(cacheID, {});
                    }
                    cache = $(document).data(cacheID);

                    //check for cached data
                    if (cache.loading === false && cache.sourceData) { //take source from cache
                        this.sourceData = cache.sourceData;
                        this.doPrepend();
                        success.call(this);
                        return;
                    } else if (cache.loading === true) { //cache is loading, put callback in stack to be called later
                        cache.callbacks.push($.proxy(function () {
                            this.sourceData = cache.sourceData;
                            this.doPrepend();
                            success.call(this);
                        }, this));

                        //also collecting error callbacks
                        cache.err_callbacks.push($.proxy(error, this));
                        return;
                    } else { //no cache yet, activate it
                        cache.loading = true;
                        cache.callbacks = [];
                        cache.err_callbacks = [];
                    }
                }
                
                //loading sourceData from server
                $.ajax({
                    url: source,
                    type: 'get',
                    cache: false,
                    dataType: 'json',
                    success: $.proxy(function (data) {
                        if(cache) {
                            cache.loading = false;
                        }
                        this.sourceData = this.makeArray(data);
                        if($.isArray(this.sourceData)) {
                            if(cache) {
                                //store result in cache
                                cache.sourceData = this.sourceData;
                                //run success callbacks for other fields waiting for this source
                                $.each(cache.callbacks, function () { this.call(); }); 
                            }
                            this.doPrepend();
                            success.call(this);
                        } else {
                            error.call(this);
                            if(cache) {
                                //run error callbacks for other fields waiting for this source
                                $.each(cache.err_callbacks, function () { this.call(); }); 
                            }
                        }
                    }, this),
                    error: $.proxy(function () {
                        error.call(this);
                        if(cache) {
                             cache.loading = false;
                             //run error callbacks for other fields
                             $.each(cache.err_callbacks, function () { this.call(); }); 
                        }
                    }, this)
                });
            } else { //options as json/array
                this.sourceData = this.makeArray(source);
                    
                if($.isArray(this.sourceData)) {
                    this.doPrepend();
                    success.call(this);   
                } else {
                    error.call(this);
                }
            }
        }
363485
function(event, callback) {
    if ('ready-success-fail'.split('-').indexOf(event) >= 0 && _typeof(callback) == 'function')
      _events[event] = callback;
  }
1161307
function(url, success, fail) {
        success = success || noop;
        fail = fail || noop;

        //if there's a queue
        if (queue[url] instanceof Array) {
            //just add it
            return queue[url].push({
                success: success,
                fail: fail
            });
        }

        //otherwise there is not a queue
        //so let's create one
        queue[url] = [{
            success: success,
            fail: fail
        }];

        var xhr;

        if(typeof XMLHttpRequest !== 'undefined') {
            xhr = new XMLHttpRequest();
        } else {
            var versions = [
                'MSXML2.XmlHttp.5.0',
                'MSXML2.XmlHttp.4.0',
                'MSXML2.XmlHttp.3.0',
                'MSXML2.XmlHttp.2.0',
                'Microsoft.XmlHttp'];

             for(var i = 0; i < versions.length; i++) {
                try {
                    xhr = new ActiveXObject(versions[i]);
                    break;
                }
                catch(e){}
             }
        }

        if(!xhr) {
            //fail the queue
            queue[url].forEach(function(callback) {
                callback.fail(null);
            });

            delete queue[url];
            return;
        }

        var process = function() {
            if(xhr.readyState < 4) {
                return;
            }

            if(xhr.status >= 404 && xhr.status < 600) {
                //fail the queue
                queue[url].forEach(function(callback) {
                    callback.fail(xhr);
                });

                delete queue[url];
                return;
            }

            if(xhr.status !== 200) {
                return;
            }

            // all is well
            if(xhr.readyState === 4) {
                var response = xhr.responseText;

                try {
                    response = JSON.parse(response);
                } catch(e) {}

                //fail the queue
                queue[url].forEach(function(callback) {
                    callback.success(response, xhr);
                });

                delete queue[url];
            }
        };

        xhr.onreadystatechange = process;
        xhr.open('GET', url, true);
        xhr.send('');
    }
583041
function(err, status) {
					if (err) {
						callback(err);
						return;
					}

					if (status || status === 'OK') {
						report.inserted += _.isNumber(status) ? status : 1;
					} else {
						//	Hm...
						report.errors += 1;
					}

					AddRecursive();
				}
1204552
function(err, data, response) {

				// call the 'response' callback, if provided using 'node' style callback pattern
				if (options.complete) {
					options.complete.call(model, err, data, response, options);
				}

				// trigger any event listeners for "complete"
				model.trigger('complete', err, data, response, options);
			}
1161358
function responseCallback(response, model, success) {
        // Add response to a hash that will eventually be returned through the promise
        responses[model.cid] = {
            success: success,
            response: response
          };
        // If we have reached the total of number of expected responses, then resolve or reject the promise
        if (responsesFailed + responsesSucceeded === numberOfSaves) {
          if (responsesFailed > 0) {
            // Rollback if any responses have failed
            if (options.rollback) {
              _.each(formModel.getTrackedModels(), function(model) {
                model.set(oldValues[model.cid]);
                if (responses[model.cid].success) {
                  model.save();
                }
              });
            }
            formModel.trigger('save-fail', responses);
            deferred.reject(responses);
          } else {
            formModel.trigger('save-success', responses);
            deferred.resolve(responses);
          }
        }
      }
976682
function(req, res) {
        if (res.locals.success) {
            options.success(model, response);
        } else {
            options.error(model, response);
        }
    }
524445
function( callback ){
      var tm = this;

      setTimeout(function () {
        var returnValue;

        //check for template existance.
        if (tm.template) {
          tm._tokenize();
          returnValue = tm._tokens;

          // execute callback.
          if (callback) {
            callback( returnValue );
          }
        } else {
          throw "ParseError: No template to parse.";
        }
      }, 0);
    }
974104
function () {

    this._success = [];
    this._failed = [];
    this._cached = false;

    this._process = null;

    this._calls = 0;

    this._showProgress = true;
    this._showError = true;
    var _this = this;
    this.success = function () {
        _this.onSuccess.apply(_this, arguments);
    };

    this.error = function () {
        _this.onError.apply(_this, arguments);
    };
}
607480
def error_handler(f):
    """"""
    @wraps(f)
    def inner(*args, **kwargs):
        try:
            return f(*args, **kwargs)
        except ReceiverDoesNotExist:
            return jsonify(
                status=404,
                description='Receiver does not exists.'
            ), 404
        except InvalidPayload as e:
            return jsonify(
                status=415,
                description='Receiver does not support the'
                            ' content-type "%s".' % e.args[0]
            ), 415
        except WebhooksError:
            return jsonify(
                status=500,
                description='Internal server error'
            ), 500
    return inner
75133
function error(err, req, res, next) {
  // log it
  if (!test) console.error(err.stack);

  // respond with 500 "Internal Server Error".
  res.status(500);
  res.send('Internal Server Error');
}
1030567
function (callback) {
		callbacks.fail.push(function () {
			var result = callback.apply(this, arguments);
			if (result) {
				failMessage(result);
			}
		});
		return execute;
	}
1373002
function internalError(response, message, body) {
  var content = errorContent(ErrorType.server, message, body);
  send(response, content, StatusCode.internalServerError);
}