build protocol level error message based on Error object
977996
def build_raw_error_message(protocol_exception):
    """"""
    message = ErrorMessage(
        id=protocol_exception.id,
        code=protocol_exception.code,
        tracing=protocol_exception.tracing,
        description=protocol_exception.description,
    )

    return message
1065245
function erroz(error) {

    var errorFn = function (data) {

        //apply all attributes on the instance
        for (var errKey in errorFn.prototype) {
            if (errorFn.prototype.hasOwnProperty(errKey)) {
                this[errKey] = errorFn.prototype[errKey];
            }
        }

        //overwrite message if invoked with string
        if (typeof data === "string") {
            this.message = data;
            data = {};
        }

        this.data = data || {};

        this.message = this.message || erroz.options.renderMessage(error.template || "", this.data);

        errorFn.super_.call(this, this.constructor);
    };

    util.inherits(errorFn, AbstractError);

    //add static error properties (name, status, etc)
    for (var errKey in error) {
        if (error.hasOwnProperty(errKey)) {
            errorFn.prototype[errKey] = error[errKey];
        }
    }

    /**
     * return an object containing only JSend attributes
     * @returns {{status: *, code: *, message: *, data: (*|string|Object[]|Object|String)}}
     */
    errorFn.prototype.toJSend = function () {
        var data = this.data;

        if (erroz.options.includeStack && this.stack) {
            data.stack = this.stack;
        }

        if (!this.status) {
            this.status = deriveStatusFromStatusCode(this.statusCode);
        }

        return {
            status: this.status,
            code: this.code,
            message: this.message,
            data: data
        };
    };

    return errorFn;
}
1066611
function AbstractCliError(message, statusCode) {
	Error.call(this, message, statusCode);
	Error.captureStackTrace(this, AbstractCliError);

	this.message = message || this.message
}
912908
function WError(options)
{
	Error.call(this);

	var args, cause, ctor;
	if (typeof (options) === 'object') {
		args = Array.prototype.slice.call(arguments, 1);
	} else {
		args = Array.prototype.slice.call(arguments, 0);
		options = undefined;
	}

	if (args.length > 0) {
		this.message = mod_extsprintf.sprintf.apply(null, args);
	} else {
		this.message = '';
	}

	if (options) {
		if (options instanceof Error) {
			cause = options;
		} else {
			cause = options.cause;
			ctor = options.constructorOpt;
		}
	}

	Error.captureStackTrace(this, ctor || this.constructor);
	if (cause)
		this.cause(cause);

}
233278
def raise_if_error(frame):
    
    if "status" not in frame or frame["status"] == b"\x00":
        return
    codes_and_exceptions = {
        b"\x01": exceptions.ZigBeeUnknownError,
        b"\x02": exceptions.ZigBeeInvalidCommand,
        b"\x03": exceptions.ZigBeeInvalidParameter,
        b"\x04": exceptions.ZigBeeTxFailure
    }
    if frame["status"] in codes_and_exceptions:
        raise codes_and_exceptions[frame["status"]]()
    raise exceptions.ZigBeeUnknownStatus()
304479
def build_parameters_error(cls, errors=None):
        """"""
        errors = [errors] if not isinstance(errors, list) else errors
        return cls(Status.PARAMETERS_ERROR, errors)
414997
function buildErrorObject(error) {
		var msg = error.message || 'Unknown error occurred';
		var errorName = errorTypes.includes(error.name) ? error.name : 'Error';
		var ErrConstructor = window[errorName] || Error;

		if (error.stack) {
			msg += '\n' + error.stack.replace(error.message, '');
		}
		return new ErrConstructor(msg);
	}
1358909
def get_error(response):
    """"""

    errors = {
        400: BadRequestError,
        401: UnauthorizedError,
        403: AccessDeniedError,
        404: NotFoundError,
        429: RateLimitExceededError,
        500: ServerError,
        502: BadGatewayError,
        503: ServiceUnavailableError
    }

    error_class = HTTPError
    if response.status_code in errors:
        error_class = errors[response.status_code]

    return error_class(response)
841063
def _error_message(self):
        
        body = self._deserialize()
        return body.get('message', body) if isinstance(body, dict) else body
203917
def logic(self, data):
        
        try:
            msg = Message(data, self)
            msg.validate(self.protocol_version)
        except (ValueError, vol.Invalid) as exc:
            _LOGGER.warning('Not a valid message: %s', exc)
            return None

        message_type = self.const.MessageType(msg.type)
        handler = message_type.get_handler(self.handlers)
        ret = handler(msg)
        ret = self._route_message(ret)
        ret = ret.encode() if ret else None
        return ret
452561
def buildErrorResponse(self, request, error=None):
        
        if error is not None:
            cls, e, tb = error
        else:
            cls, e, tb = sys.exc_info()

        return generate_error(request, cls, e, tb, self.gateway.debug)
1300926
def _update_error_pointer(error, pointer_or_prefix):
    
    if error.pointer:
        error.pointer = '{}.{}'.format(pointer_or_prefix, error.pointer)
    else:
        error.pointer = '{}'.format(pointer_or_prefix)
    return error
1263787
function TypeError (msg, spec, value) {
  const e = Error(msg)
  return Object.assign(e, { spec, value })
}
1121101
def error_handler(task):
    """"""
    @wraps(task)
    def wrapper(self, *args, **kwargs):
        try:
            return task(self, *args, **kwargs)
        except Exception as e:
            self.connected = False
            if not self.testing:
                exc_type, exc_obj, exc_tb = sys.exc_info()
                fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
                error_message = (
                    "[" + str(datetime.now()) + "] Error in task \"" +
                    task.__name__ + "\" (" +
                    fname + "/" + str(exc_tb.tb_lineno) +
                    ")" + e.message
                )
                self.logger.error("%s: RPC instruction failed" % error_message)
    return wrapper
8351
function Message(name, attrs, opts) {
  opts = opts || {};

  if (!types.isValidName(name)) {
    throw new Error(f('invalid message name: %s', name));
  }
  this._name = name;

  var recordName = f('org.apache.avro.ipc.%sRequest', name);
  this._requestType = types.createType({
    name: recordName,
    type: 'record',
    namespace: opts.namespace || '', // Don't leak request namespace.
    fields: attrs.request
  }, opts);
  // We remove the record from the registry to prevent it from being exported
  // in the protocol's schema.
  delete opts.registry[recordName];

  if (!attrs.response) {
    throw new Error('missing response');
  }
  this._responseType = types.createType(attrs.response, opts);

  var errors = attrs.errors || [];
  errors.unshift('string');
  this._errorType = types.createType(errors, opts);

  this._oneWay = !!attrs['one-way'];
  if (this._oneWay) {
    if (this._responseType.getTypeName() !== 'null' || errors.length > 1) {
      throw new Error('unapplicable one-way parameter');
    }
  }
}
243003
function sendError (
  event, message, recordName, socketWrapper, onError, options, context, metaData
) {
  options.logger.error(event, message, metaData)
  if (socketWrapper) {
    socketWrapper.sendError(C.TOPIC.RECORD, event, message)
  }
  if (onError) {
    onError.call(context, event, message, recordName, socketWrapper)
  }
}
1092476
async def on_raw_error(self, message):
        
        error = protocol.ServerError(' '.join(message.params))
        await self.on_data_error(error)