A decorator that logs a call into the global error context.

    This is probably for internal use only.
771649
def _record_call(func):
    

    @wraps(func)
    def wrapper(*args, **kwargs):
        global global_error_context

        # log a call as about to take place
        if global_error_context is not None:
            key = CallLogKey(name=func.__name__,
                             args=[serialize_object_for_logging(arg) for arg in args],
                             kwargs={k: serialize_object_for_logging(v) for k, v in kwargs.items()})

            pre_entry = CallLogValue(timestamp_in=datetime.utcnow(),
                                     timestamp_out=None,
                                     return_value=None)
            global_error_context.log[key] = pre_entry

        val = func(*args, **kwargs)

        # poke the return value of that call in
        if global_error_context is not None:
            post_entry = CallLogValue(timestamp_in=pre_entry.timestamp_in,
                                      timestamp_out=datetime.utcnow(),
                                      return_value=serialize_object_for_logging(val))
            global_error_context.log[key] = post_entry

        return val

    return wrapper
533650
def RaiseIfNotErrorSuccess(result, func = None, arguments = ()):
    
    if result != ERROR_SUCCESS:
        raise ctypes.WinError(result)
    return result
1095976
def add_log_callback(callback):
    """"""
    global _log_callbacks

    if not callable(callback):
        raise ValueError("Callback must be callable")

    _log_callbacks.add(callback)
    return callback
337674
def clean_fail(func):
    '''
    
    '''
    def func_wrapper(*args, **kwargs):
        try:
            return func(*args, **kwargs)
        except botocore.exceptions.ClientError as e:
            print(str(e), file=sys.stderr)
            sys.exit(1)
    return func_wrapper
1233202
def try_catch(func, *args, **kwargs):
    '''
    
    '''
    try:
        return log_debug(func, *args, **kwargs)
    except Exception as exc:
        logging.debug('Error in "%s" in thread %s: %s', func.__name__, current_thread(), exc)
        return exc
37060
def error_msg_callback(self, callback):
        """"""
        if callable(callback):
            self._error_msg_callback = callback
        else:
            self._error_msg_callback = None
1005012
def log_error(self, message, *args, **kwargs):
        # pylint: disable=W0221
        
        self._service.log(logging.ERROR, message, *args, **kwargs)
162091
def errorObject(object, cat, format, *args):
    
    doLog(ERROR, object, cat, format, args)

    # we do the import here because having it globally causes weird import
    # errors if our gstreactor also imports .log, which brings in errors
    # and pb stuff
    if args:
        raise SystemExit(format % args)
    else:
        raise SystemExit(format)
1003565
def error(self, code=500):
        
        def wrapper(handler):
            self.error_handler[int(code)] = handler
            return handler
        return wrapper
398277
function (err, ctx, thisArg) {
    this.errorHanders.forEach(function (fn) {
      fn.call(thisArg, err, ctx);
    });

    return this;
  }
656610
def log_template_errors(logger, log_level=logging.ERROR):
    
    if not (isinstance(log_level, int) and
            log_level in logging._levelNames):
        raise ValueError('Invalid log level %s' % log_level)

    decorators = [
        _log_template_string_if_invalid(logger, log_level),
        _log_unicode_errors(logger, log_level),
        _always_strict_resolve,
    ]
    if django.VERSION < (1, 8):
        decorators.append(_patch_invalid_var_format_string)

    @decorator
    def function(f, *args, **kwargs):
        return reduce(__apply, decorators, f)(*args, **kwargs)

    return function
742210
function () {
				if (typeof global.onerror !== "undefined") {
					var self = this;
					global.onerror = function (msg, url, line) {
						self.error("[" + msg + " on line " + line + " of " + url + "]", 0);
					};
					return true;
				} else {
					return false;
				}
			}
689055
def error_handling(cls, fn):
        """"""
        def wrapper(*args, **kwargs):
            try:
                result = fn(*args, **kwargs)
                return result
            except InvalidRequestError as e:
                write_exception(e)

                if hasattr(e, 'request'):
                    write_error_message('request {0}'.format(repr(e.request)))
                if hasattr(e, 'response'):
                    write_error_message('response {0}'.format(repr(e.response)))

                raise e
        return wrapper
1075588
def _log_unicode_errors(logger, log_level):
    
    def log_debug_render(*args, **kwargs):
        try:
            return debug_variable_node_render(*args, **kwargs)
        except UnicodeDecodeError:
            logger.log(
                log_level,
                "UnicodeDecodeError in template rendering",
                exc_info=True)
        return ''

    def log_render(*args, **kwargs):
        try:
            return variable_node_render(*args, **kwargs)
        except UnicodeDecodeError:
            logger.log(
                log_level,
                "UnicodeDecodeError in template rendering",
                exc_info=True)
        return ''

    patch_base = patch.object(VariableNode, 'render', log_render)
    patch_all = patch_base
    if django.VERSION < (1, 9):
        from django.template.debug import DebugVariableNode
        patch_debug = patch.object(DebugVariableNode, 'render',
                                   log_debug_render)
        patch_all = _compose(patch_all, patch_debug)
    return lambda f: patch_all(f)
676483
def log_call(call_name):
    """"""
    def decorator(f):
        @wraps(f)
        def wrapper(*args, **kw):
            instance = args[0]
            instance.logger.info(call_name, {"content": request.get_json()})
            return f(*args, **kw)
        return wrapper
    return decorator
668184
def error(self, message, *args, **kwargs):
        
        self._log(logging.ERROR, message, *args, **kwargs)
989912
def error_handler(f):
    """"""
    @wraps(f)
    def inner(*args, **kwargs):
        try:
            return f(*args, **kwargs)
        except NoResultFound:
            abort(404)
        except IntegrityError:
            abort(500)
    return inner