失败订单(未成功创建入broker)

        Arguments:
            reason {str} -- 失败原因
14543
def failed(self, reason=None):
        
        # 订单创建失败(如废单/场外废单/价格高于涨停价/价格低于跌停价/通讯失败)
        self._status = ORDER_STATUS.FAILED
        self.reason = str(reason)
197957
function Args() {
    if (argv._.length >= 1) {
        try {
            // Attempt to parse 1st argument as JSON string
            _.extend(this, JSON.parse(argv._[0]));
        } catch (err) {
            // Pass, we must be in the console so don't worry about it
        }
    }
}
584435
function doCallback(callback, reason, value) {
  // Note:  Could delay callback call until later, as When.js does, but this
  // loses the stack (particularly for bluebird long traces) and causes
  // unnecessary delay in the non-exception (common) case.
  try {
    // Match argument length to resolve/reject in case callback cares.
    // Note:  bluebird has argument length 1 if value === undefined due to
    // https://github.com/petkaantonov/bluebird/issues/170
    // If you are reading this and want similar behavior, I'll consider it.
    if (reason) {
      callback(reason);
    } else {
      callback(null, value);
    }
  } catch (err) {
    later(() => { throw err; });
  }
}
634752
function normalize(reasons: { [string]: (Change, context: any) => any }): * {
    return (change, reason, context) => {
        const reasonFn = reasons[reason];
        if (reasonFn) {
            reasonFn(change, context);
        }
    };
}
580448
def _extract_reason(kw):
    
    try:
        # we "often" have a REASON
        reason = kw['REASON']
        try:
            # ...and sometimes even have a REMOTE_REASON
            reason = '{}, {}'.format(reason, kw['REMOTE_REASON'])
        except KeyError:
            pass  # should still be the 'REASON' error if we had it
    except KeyError:
        reason = "unknown"
    return reason
255952
function resolve(opt) {
	if (opt instanceof Transporters.Base) {
		return opt;
	} else if (_.isString(opt)) {
		let TransporterClass = getByName(opt);
		if (TransporterClass)
			return new TransporterClass();

		if (opt.startsWith("nats://"))
			TransporterClass = Transporters.NATS;
		else if (opt.startsWith("mqtt://") || opt.startsWith("mqtts://"))
			TransporterClass = Transporters.MQTT;
		else if (opt.startsWith("redis://") || opt.startsWith("rediss://"))
			TransporterClass = Transporters.Redis;
		else if (opt.startsWith("amqp://") || opt.startsWith("amqps://"))
			TransporterClass = Transporters.AMQP;
		else if (opt.startsWith("kafka://"))
			TransporterClass = Transporters.Kafka;
		else if (opt.startsWith("stan://"))
			TransporterClass = Transporters.STAN;
		else if (opt.startsWith("tcp://"))
			TransporterClass = Transporters.TCP;

		if (TransporterClass)
			return new TransporterClass(opt);
		else
			throw new BrokerOptionsError(`Invalid transporter type '${opt}'.`, { type: opt });

	} else if (_.isObject(opt)) {
		let TransporterClass = getByName(opt.type || "NATS");

		if (TransporterClass)
			return new TransporterClass(opt.options);
		else
			throw new BrokerOptionsError(`Invalid transporter type '${opt.type}'.`, { type: opt.type });
	}

	return null;
}
841604
function (err) {
        if (err) {
          reject(err);
        } else if (arguments.length === 2) { // single param?
          resolve(arguments[1]);
        } else { // multiple params?
          var cbArgsArray = self.toArgsArray(arguments);
          resolve(cbArgsArray.slice(1)); // remove err arg
        }
      }
329677
def parse_reason(response, content):
    
    def first_error(data):
        errors = data['error']['errors']
        if len(errors) > 1:
            # we have more than one error. We should capture that?
            logging.info('Received {} errors'.format(len(errors)))
        return errors[0]

    try:
        json_data = json.loads(content)
        return first_error(json_data)['reason']
    except:
        return response.reason
782428
function(status, reasonPhrase, headers) {
        var self = this;

        each(headers || reasonPhrase, function(value, name) {
          self.setHeader(name, value);
        });

        return this._super(status, typeof reasonPhrase === 'string' ? reasonPhrase : undefined);
      }
645606
function error () {
  if (mocking) {
    cli.stderr += stripAnsi(concatArguments(arguments) + '\n')
  } else {
    console.error.apply(null, arguments)
  }
}
830637
def parse_args(args):
    
    parser = argparse.ArgumentParser(
        description='Starts the REST API application and connects to a '
        'specified validator.')

    parser.add_argument('-B', '--bind',
                        help='identify host and port for API to run on \
                        default: http://localhost:8008)',
                        action='append')
    parser.add_argument('-C', '--connect',
                        help='specify URL to connect to a running validator')
    parser.add_argument('-t', '--timeout',
                        help='set time (in seconds) to wait for validator \
                        response')
    parser.add_argument('--client-max-size',
                        type=int,
                        help='the max size (in bytes) of a request body')
    parser.add_argument('-v', '--verbose',
                        action='count',
                        default=0,
                        help='enable more verbose output to stderr')
    parser.add_argument('--opentsdb-url',
                        help='specify host and port for Open TSDB database \
                        used for metrics')
    parser.add_argument('--opentsdb-db',
                        help='specify name of database for storing metrics')

    try:
        version = pkg_resources.get_distribution(DISTRIBUTION_NAME).version
    except pkg_resources.DistributionNotFound:
        version = 'UNKNOWN'

    parser.add_argument(
        '-V', '--version',
        action='version',
        version=(DISTRIBUTION_NAME + ' (Hyperledger Sawtooth) version {}')
        .format(version),
        help='display version information')

    return parser.parse_args(args)
682720
function handleResponseError(error) {
    console.error('handleResponseError', error)
    let reason
    const status = error.response.status

    if (status === 404) {
        reason = wrap('接口不存在')
    } else {
        reason = wrap(defaultErrorMessage)
    }

    return reason
}
59863
function getArgs (fn) {
  const fnString = fn.toString();
  const argList = /[(]([^)]*)[)]/.exec(fnString)[ 1 ].split(',');
  return argList.map(String.prototype.trim);
}
1198969
function prepareArgsForEncode (aci, params) {
  if (!aci) return params
  // Validation
  const validation = aci.arguments
    .map(
      ({ type }, i) =>
        validate(type, params[i])
          ? `Argument index: ${i}, value: [${params[i]}] must be of type [${type}]`
          : false
    ).filter(e => e)
  if (validation.length) throw new Error('Validation error: ' + JSON.stringify(validation))

  return aci.arguments.map(({ type }, i) => transform(type, params[i]))
}
1304996
function wrapArguments(trace, clientState, hooks) {
  //wrap any callbacks found in the arguments
  var args = trace.args;
  var handler = clientState.rules.handleArgs(trace.funInfo.name);
  if (handler) {
    handler(trace, clientState);
  }
  for (var i = args.length - 1; i >= 0; i--) {
    var a = args[i];
    if (util.isFunction(a) && !a.__concurix_blacklisted) {
      var callbackState = {
        modInfo: clientState.modInfo,
        rules: clientState.rules,
        callbackOf: trace
      };

      if (wrap.isWrapper(args[i])) {
        args[i].__concurix_proxy_state__
          .module((trace.calledBy && trace.calledBy.moduleName) || 'root')
          .state(callbackState)
          .nameIfNeeded(trace.funInfo.name + ' callback')
          .getProxy();
      }
      else {
        args[i] = wrap(a)
          .before(hooks.beforeHook)
          .after(hooks.afterHook)
          .module((trace.calledBy && trace.calledBy.moduleName) || 'root')
          .state(callbackState)
          .nameIfNeeded(trace.funInfo.name + ' callback')
          .getProxy();
      }
      trace.origFunctionArguments = trace.origFunctionArguments || [];
      trace.origFunctionArguments.push(a);
    }
  }
}
232395
def _dbus_exception_to_reason(exc, args):
    '''
    
    '''
    error = exc.get_dbus_name()
    if error == 'error.unknown_config':
        return "Unknown configuration '{0}'".format(args['config'])
    elif error == 'error.illegal_snapshot':
        return 'Invalid snapshot'
    else:
        return exc.get_dbus_name()
1267672
def arg(params)
      rpc_desc.input.decode_json(params.reject { |k, _v| k == :selections }.to_json)
    end