capture: capture object onSuccess: function (Map of url -> SourceMapConsumer) onFailure: function (string)
491641
function getSourceMapsForCapture(capture, onFailure, onSuccess) {
  const urls = new Set();
  const sourcemaps = new Map();
  for (const id in capture.refs) {
    const ref = capture.refs[id];
    if ((ref.type === 'ScriptExecutable' ||
        ref.type === 'EvalExecutable' ||
        ref.type === 'ProgramExecutable' ||
        ref.type === 'FunctionExecutable') && ref.value.url) {
      urls.add(ref.value.url);
    }
  }
  urls.forEach((url) => {
    getSourceMapForUrl(url, onFailure, (sourcemap) => {
      sourcemaps.set(url, sourcemap);
      urls.delete(url);
      if (urls.size === 0) {
        onSuccess(sourcemaps);
      }
    });
  });
  if (urls.size === 0) {
    console.warn('No source information found in capture');
    onSuccess(sourcemaps);
  }
}
707198
public void onFailure (Throwable cause)
    {
        if (_errorNear == null) {
            Popups.error(formatError(cause));
        } else {
            Popups.errorBelow(formatError(cause), _errorNear);
        }
        Console.log("Service request failed", cause);
    }
821690
def _capture_as_text(capture: Callable[..., Any]) -> str:
    """"""
    if not icontract._represent._is_lambda(a_function=capture):
        signature = inspect.signature(capture)
        param_names = list(signature.parameters.keys())

        return "{}({})".format(capture.__qualname__, ", ".join(param_names))

    lines, lineno = inspect.findsource(capture)
    filename = inspect.getsourcefile(capture)
    decorator_inspection = icontract._represent.inspect_decorator(lines=lines, lineno=lineno, filename=filename)

    call_node = decorator_inspection.node

    capture_node = None  # type: Optional[ast.Lambda]

    if len(call_node.args) > 0:
        assert isinstance(call_node.args[0], ast.Lambda), \
            ("Expected the first argument to the snapshot decorator to be a condition as lambda AST node, "
             "but got: {}").format(type(call_node.args[0]))

        capture_node = call_node.args[0]

    elif len(call_node.keywords) > 0:
        for keyword in call_node.keywords:
            if keyword.arg == "capture":
                assert isinstance(keyword.value, ast.Lambda), \
                    "Expected lambda node as value of the 'capture' argument to the decorator."

                capture_node = keyword.value
                break

        assert capture_node is not None, "Expected to find a keyword AST node with 'capture' arg, but found none"
    else:
        raise AssertionError(
            "Expected a call AST node of a snapshot decorator to have either args or keywords, but got: {}".format(
                ast.dump(call_node)))

    capture_text = decorator_inspection.atok.get_text(capture_node.body)

    return capture_text
35609
def _capture(self, args, kwargs):
        ''''''
        self.called = self.called + 1
        self.method_args.append(args)
        self.named_method_args.append(kwargs)
        self.never_called = False
488315
@Override
    public void onFailure(Response response, Throwable t, JSONObject extendedInfo) {
        if (isAuthorizationRequired(response)) {
            processResponseWrapper(response, true);
        } else {
            listener.onFailure(response, t, extendedInfo);
        }
    }
255367
function handlePreResponseError(server) {
        server.ext('onPreResponse', function (request, reply) {
            var response = request.response;
            var originalResponse = response;
            var msg;

            // No error, keep going with the reply as normal
            if (!response.isBoom) { reply.continue(); return; }

            // we need to convert to AppError if it is not already
            if (!(response instanceof AppError)) {
                msg = response.message || (response + '');

                // if legit 404 be sure to use that code (happens with not found in /dist on local)
                if (msg.indexOf('404:') >= 0 ||
                    (response.output && response.output.payload &&
                    response.output.payload.statusCode === 404)) {

                    response = new AppError({
                        code: 'not_found',
                        msg: 'The resource ' + request.url.path + ' was not found'
                    });
                }
                else {
                    msg = response.message || (response + '');
                    if (response.data) { msg += ' : ' + response.data; }

                    log.info(msg);

                    response = new AppError({
                        code: response.code || 'api_error',
                        msg: msg,
                        err: response
                    });
                }
            }

            var code = response.code || 'unknown_error';
            var err = errorDecoder[code] || errorDecoder['unknown_error'];
            var url = request.path;

            if (err.httpErrorCode === 404) {
                trackingService.pageNotFound({
                    caller: request.caller,
                    url: routeHelper.getBaseUrl(request.app.name) + url
                });
            }
            else {
                log.error(request.method + ' ' + url + ' (' + err.friendlyMessage + ')',
                    { err: originalResponse }   );
            }

            //TODO: this hack sucks, but needed quick way to display error page; do better!
            if (pancakes.getContainer() === 'webserver') {

                // hack fix for issue when error on trust site
                if (request.app && request.app.name === 'trust') {
                    reply().redirect(routeHelper.getBaseUrl('contact') + '?notify=loginFailure');
                }
                // else show error pages
                else {
                    var errUrl = err.httpErrorCode === 404 ? '/error404' : '/error500';
                    pancakes.processRoute({ request: request, reply: reply, urlOverride: errUrl, returnCode: err.httpErrorCode });
                }
            }
            else {
                reply(Boom.create(err.httpErrorCode, err.friendlyMessage));
            }
        });
    }
459047
function capturePayload (endpoint, payload) {
  var dumpfile = path.join(os.tmpdir(), 'opbeat-' + endpoint + '-' + Date.now() + '.json')
  fs.writeFile(dumpfile, JSON.stringify(payload), function (err) {
    if (err) console.log('could not capture intake payload: %s', err.message)
    else console.log('intake payload captured: %s', dumpfile)
  })
}
1015508
function setHashOrThrowError(parseMap, routeObject) {
    var route = routeObject.route;
    var get = routeObject.get;
    var set = routeObject.set;
    var call = routeObject.call;

    getHashesFromRoute(route).
        map(function mapHashToString(hash) { return hash.join(','); }).
        forEach(function forEachRouteHash(hash) {
            if (get && parseMap[hash + 'get'] ||
                set && parseMap[hash + 'set'] ||
                    call && parseMap[hash + 'call']) {
                throw new Error(errors.routeWithSamePrecedence + ' ' +
                               prettifyRoute(route));
            }
            if (get) {
                parseMap[hash + 'get'] = true;
            }
            if (set) {
                parseMap[hash + 'set'] = true;
            }
            if (call) {
                parseMap[hash + 'call'] = true;
            }
        });
}
367766
function copyUrlParameters(mockHandler, origSettings) {
		//parameters aren't captured if the URL isn't a RegExp
		if (!(mockHandler.url instanceof RegExp)) {
			return;
		}
		//if no URL params were defined on the handler, don't attempt a capture
		if (!mockHandler.hasOwnProperty('urlParams')) {
			return;
		}
		var captures = mockHandler.url.exec(origSettings.url);
		//the whole RegExp match is always the first value in the capture results
		if (captures.length === 1) {
			return;
		}
		captures.shift();
		//use handler params as keys and capture resuts as values
		var i = 0,
		capturesLength = captures.length,
		paramsLength = mockHandler.urlParams.length,
		//in case the number of params specified is less than actual captures
		maxIterations = Math.min(capturesLength, paramsLength),
		paramValues = {};
		for (i; i < maxIterations; i++) {
			var key = mockHandler.urlParams[i];
			paramValues[key] = captures[i];
		}
		origSettings.urlParams = paramValues;
	}
745223
def capture(self, *args, **kwargs):
        
        if not self.is_enabled():
            return

        data = self.build_msg(*args, **kwargs)

        future = self.send(callback=kwargs.get('callback', None), **data)

        return (data['event_id'], future)
1133744
public void onFailure(Throwable t) {

        if ((t instanceof StatusCodeException) && (((StatusCodeException)t).getStatusCode() == 0)) {
            // a status code 0 indicates the client aborted the request, most likely when leaving the page, this should be ignored
            return;
        } else if ((t instanceof StatusCodeException) && (((StatusCodeException)t).getStatusCode() == 500)) {
            // a server error 500 most likely indicates an expired session and there for insufficient user rights to access any GWT service
            CmsErrorDialog dialog = new CmsErrorDialog(Messages.get().key(Messages.GUI_SESSION_EXPIRED_0), null);
            dialog.center();
        } else {
            CmsErrorDialog.handleException(t);
        }
        // remove the overlay
        stop(false);
    }
940004
function onCollectionRetrievalFailure( serverResponse ) {
			self.logInterface.error( self.logPrefix + "Unable to retrieve the collection from the server.",
				serverResponse );
			self.__entityCacheRaw = null;

			self.scope.$emit( "absyncError", serverResponse );

			if( self.throwFailures ) {
				throw serverResponse;
			}
		}
1173916
public void saveContent(
        JavaScriptObject newValues,
        final I_CmsStringCallback onSuccess,
        final I_CmsErrorCallback onFailure) {

        m_apiRoot.getRpcHelper().executeRpc(
            CmsXmlContentUgcApi.SERVICE.saveContent(
                m_content.getSessionId(),
                CmsJsUtils.convertJsObjectToMap(newValues),
                new AsyncCallback<Map<String, String>>() {

                    @SuppressWarnings("synthetic-access")
                    public void onFailure(Throwable caught) {

                        CmsUgcException formException = (CmsUgcException)caught;
                        m_apiRoot.handleError(formException, onFailure);
                    }

                    public void onSuccess(Map<String, String> result) {

                        if ((result == null) || result.isEmpty()) {
                            onSuccess.call("");
                        } else {
                            JavaScriptObject validationErrorsJso = CmsJsUtils.convertMapToJsObject(result);
                            onFailure.call(CmsUgcConstants.ErrorCode.errValidation.toString(), "", validationErrorsJso);
                        }
                    }
                }));

    }
1346889
function readFailureCallback(e) {
    if (this._readyState === FileReader.DONE) {
        return;
    }

    this._readyState = FileReader.DONE;
    this._result = null;
    this._error = new FileError(e);

    if (typeof this.onerror === "function") {
        this.onerror(new ProgressEvent("error", {target:this}));
    }

    if (typeof this.onloadend === "function") {
        this.onloadend(new ProgressEvent("loadend", {target:this}));
    }
}
129112
function(url, callback) {
        if (isBrowser) {
            // Browser environments can't pipe, so download the file and add it
            return this.getImageDataFromUrl(url, function(err, data) {
                if (err) {
                    return callback(err);
                }

                this.addImageFromBuffer(data, callback);
            }.bind(this));
        }

        // Pipe the source URL into a POST-request
        request({ uri: url }).pipe(request({
            method: 'POST',
            uri: this.getSignedResourceUrl('POST', this.getImagesUrl()),
            json: true,
            headers: {
                'Accept': 'application/json',
                'User-Agent': 'imboclient-js'
            },
            onComplete: function(err, res, body) {
                callback(err, body ? body.imageIdentifier : null, body, res);
            }
        }));

        return this;
    }
1194881
def start_capture(self):
        """"""
        previous_map_tool = self.canvas.mapTool()
        if previous_map_tool != self.tool:
            self.previous_map_tool = previous_map_tool
        self.canvas.setMapTool(self.tool)
        self.hide()
599533
function createContext(params, onNext) {

    var context = function defaultCall(err) {
        return context.next(err);
    };

    //additional parameters that are in effect beyond the object itself
    context.params = params || {};

    //keep us from calling next after a failure
    context.failed = false;


    /*
        Fail causes a hard stop of the process with the error
    */
    context.fail = function fail(err) {
        if (context.failed) throw new Error("Something caused Context.fail() to execute after the context is already failed.");
        failed = true;
        if (typeof err === "string") err = new Error(err);
        onNext(err);
    }


    /*
        Warn is a non-fatal informational warning error
    */
    context.warn = function warn(err) {
        if (typeof err === "string") err = new Error(err);
        console.log("Warning from mock context", err);
    }


    /*
        Call when you are finished with your step and are passing to the next handler
    */
    context.next = function next(err) {
        if (this.failed) throw new Error("Something caused Context.next() to execute after Context.fail().");
        if (err) return this.fail(err);
        onNext();
    }

    return context;

}