Creates a uniform Json response object
@param err the optional error
@param results the optional results
@constructor
494747
function(err, results) {
  if(err) {
    this.success = false;
    this.error = err;
    this.results = null;

    // customize error for error types
    if(util.isError(err)) {
      this.error = {
        message: err.message,
        type: err.type,
        arguments: err.arguments
      };
      if(NODE_ENV === 'development') {
        this.error.stack = err.stack;
      }
    }    

  } else {
    this.success = true;
    this.error = null;      
    this.results = convertToClient(results);    
  }
}
161470
void writeResult(final RpcResult<?, ?> result, final HttpServletResponse resp)
			throws IOException {
		if (result.isSuccess()) {
			resp.setStatus(HttpServletResponse.SC_OK);
			resp.setContentType(JSON_CONTENT_TYPE);
		} else {
			resp.setStatus(APPLICATION_EXC_STATUS);
			resp.setContentType(JSON_CONTENT_TYPE);
		}

		PrintWriter writer = resp.getWriter();
		result.toJson(writer, true);
		writer.flush();
	}
410510
def create_response response
      json = JSON.parse(response.body_str)
      if json.is_a?(Array)
        result = json.map {|result| Fulfil::Base.new(result)}
      else
        result = Fulfil::Base.new(json)
        if result.type == "UserError"
          raise Fulfil::UserError, result.message
        end
      end
      result
    end
734500
function formatResponseError(resp) {
    let result;

    if (resp.data.error) {
        result = resp.data.error.detail || resp.data.error;
    }
    else {
        result = resp.data.detail || JSON.stringify(resp.data);
    }

    return result.replace(/\n/g, '');
}
206333
function err(...messages) {
  console.error(...messages);
  const p = document.createElement('p');
  p.innerText = messages.join(' ');
  p.style = 'color: red';
  logElement.appendChild(p);
}
696955
public function response($result, $id, $error) {
        if ($error) { 
            $error['name'] = 'JSONRPCError';
        }
        return json_encode(array("jsonrpc" => "2.0",
                                 'result' => $result,
                                 'id' => $id,
                                 'error'=> $error));
    }
440282
function(err, result) {
      if (err && !util.isError(err)) {
        err = new Error(err);
      }
      if (callback) callback(err, result);
    }
139593
public static<R> Result<R> err(int status, String details, String ... variables) {
    	return new Result<R>(null,status,details,variables);
    }
557056
function haveResults(err, response, body) {
    var jsn;
    if (err) {
      callback(err);
      return;
    }
    //fs.writeFileSync('response.txt', JSON.stringify(response, null, '  '), 'utf8');
    if (response && response.statusCode !== 200) {
      callback('Resp Status: ' + response.statusCode);
      return;
    }
    try {
      jsn = JSON.parse(body);
    } catch(e) {
      callback('JSON Parse error:\n' + body);
      return;
    }
    if (!jsn.status || jsn.status !== 200) {
      callback('Status: ' + (jsn.status ? String(jsn.status) : '555') + ' ' + (jsn.message ? jsn.message : ''));
      return;
    }
    jsn.resultSetFiltered = jsn.resultSet.filter(function(itm) {
      return filter.indexOf(itm.tID) === -1;
    });
    callback(null, jsn, fname); // DONE - return results to caller
  }
1188955
function (err, results) {

        if (!err) {

          self._startup(server);

          if (cb) cb();

        } else {

          for (var errNum in results) {
            if (results.hasOwnProperty(errNum)) {
              if (results[errNum]) {
                console.error('  - ' + results[errNum] + '\n');
              }
            }
          }

          process.exit(1);
        }
      }
1056756
function(err, results) {

        if (!err) {

          self.sessionSubscriber = new SessionSubscriber(
            self.conf && self.conf.redis && self.conf.redis ? self.conf.redis : undefined,
            self.serverName,
            function(err) {
              if (!err) {

                console.info(' (init) REDIS     is connected  (for pub/sub)');
                console.info('        REDIS     is subscribed (C-' + self.serverName + ')');

                self._startup(server, io);

                if (cb) cb();

              } else {
                console.error(err);
                process.exit(1);
              }
            }
          );

        } else {

          for (var errNum in results) {
            if (results.hasOwnProperty(errNum) && results[errNum]) {
              console.error('  - ' + results[errNum] + '\n');
            }
          }
          process.exit(1);
        }
      }
967885
def result_or_error(response):
    
    data = response.json()
    result = data.get('result')
    if result is not None:
        return result
    raise exceptions.ApiError(response, data)
1119792
function(err, results) {
      var paperFormat = paperSize.format || "A4";
      var paperOrientation = paperSize.orientation || "portrait";
      var paperBorder = paperSize.border || "1cm";
      var paperWidth  = paperSize.width || 'false';
      var paperHeight = paperSize.height || 'false';
      var renderDelay = paperSize.delay || 500;

      /* All necessary files have been created.
       * Construct arguments and create a new phantom process.
       */
      var childArgs = [
        path.join(__dirname, "phantom-script.js"),
        results[0],
        results[1],
        results[2],
        results[3],
        results[4],
        paperFormat,
        paperOrientation,
        paperBorder,
        paperWidth,
        paperHeight,
        renderDelay,
        runningsArgs
      ];

      childProcess.execFile(phantom.path, childArgs, function(err, stdout, stderr) {
        var opPointer = new PDFResult(err, results[1]);

        if (typeof callback === "function") {
          callback(err, opPointer);
        }
      });
    }
589573
function getResult (err) {
        var res = {
            valid: true,
            errors: []
        };

        if (err !== null) {
            res.valid = false;
            res.errors.push(err);
        }

        return res;
    }
568886
def err_response(reqid, code, msg, data=None):
    
    err = { "code": code, "message": msg }
    if data:
        err["data"] = data
    return { "jsonrpc": "2.0", "id": reqid, "error": err }
809186
function toJSON( err ) {
	var keys;
	var out;
	var i;
	if ( !( err instanceof Error ) ) {
		throw new TypeError( 'invalid input argument. Must provide an error object. Value: `' + err + '`.' );
	}
	out = {};

	// Guaranteed properties:
	out.type = typeName( err );
	out.message = err.message;

	// Possible general error properties...
	if ( err.name ) {
		out.name = err.name;
	}
	if ( err.stack ) {
		out.stack = err.stack;
	}
	// Possible Node.js (system error) properties...
	if ( err.code ) {
		out.code = err.code;
	}
	if ( err.errno ) {
		out.errno = err.errno;
	}
	if ( err.syscall ) {
		out.syscall = err.syscall;
	}
	// Any enumerable properties...
	keys = getKeys( err );
	for ( i = 0; i < keys.length; i++ ) {
		out[ keys[i] ] = copy( err[ keys[i] ] );
	}
	return out;
}
1320471
function makeError(jqXHR, textStatus, errorThrown, options) {
    var Constructor = statusToError[textStatus];

    // We did not find anything in the map, which would happen if the textStatus
    // was "error". Determine whether an ``HttpError`` or an ``AjaxError`` must
    // be thrown.
    if (!Constructor) {
      Constructor = statusToError[(jqXHR.status !== 0) ? "http" : "ajax"];
    }

    return new Constructor(jqXHR, textStatus, errorThrown, options);
  }