Return error message(in dict).
760696
def error_response(message, status=400, code=None):
    """""""
    from django.http import JsonResponse
    data = {'message': message}
    if code:
        data['code'] = code
    LOG.error("Error response, status code is : {} | {}".format(status, data))
    return JsonResponse(data=data, status=status)
750603
def asDict(self):
        """"""
        return {
            'isError': self.isError,
            'message': self.message,
            'values': self.values,
            'value': self.value,
        }
52498
def _get_error_message(self, model_class, method_name, action_method_name):
        
        if action_method_name:
            return "'{}' does not have '{}' or '{}' defined.".format(model_class, method_name, action_method_name)
        else:
            return "'{}' does not have '{}' defined.".format(model_class, method_name)
402571
def errors(self):
        
        if self.ok():
            return {}

        errors = self.content

        if(not isinstance(errors, dict)):
            errors = {"error": errors}  # convert to dict for consistency
        elif('errors' in errors):
            errors = errors['errors']

        return errors
1255803
def get_error(self, i=None, unit=None,
                  uncover=None, trail=None,
                  linebreak=None, sort_by_indep=None):
        
        return self.get_value(i=i, unit=unit,
                              uncover=uncover, trail=trail,
                              linebreak=linebreak, sort_by_indep=sort_by_indep,
                              attr='_error')
1004322
def error(code, message, template):
    """"""
    if json_requested():
        return json_error(code, message)
    else:
        return render_template(template, message=message), code
656525
def try_and_error(*funcs):
    """"""
    def validate(value):
        exc = None
        for func in funcs:
            try:
                return func(value)
            except (ValueError, TypeError) as e:
                exc = e
        raise exc
    return validate
571156
def error(self, message: str) -> None:
        """"""
        if len(self._custom_error_message) > 0:
            message = self._custom_error_message
            self._custom_error_message = ''

        lines = message.split('\n')
        linum = 0
        formatted_message = ''
        for line in lines:
            if linum == 0:
                formatted_message = 'Error: ' + line
            else:
                formatted_message += '\n       ' + line
            linum += 1

        sys.stderr.write(Fore.LIGHTRED_EX + '{}\n\n'.format(formatted_message) + Fore.RESET)
        # sys.stderr.write('{}\n\n'.format(formatted_message))
        self.print_help()
        sys.exit(1)
842903
def to_dict(self, *args, **kwargs):
        """"""
        ret = super(HTTPError, self).to_dict(*args, **kwargs)
        if self.errors is not None:
            ret["errors"] = self.errors
        return ret
1083317
def error(self, msg, indent=0, **kwargs):
        """"""
        return self.logger.error(self._indent(msg, indent), **kwargs)
1268896
def error(message, code=1):
    """"""
    if message:
        print('ERROR: {0}'.format(message), file=sys.stderr)
    else:
        print(file=sys.stderr)
    sys.exit(code)
387109
def scanerror(self, msg):
        """"""
        error('scan error: ' + msg + ' on line {}'.format(self.sline))
        sys.exit(-1)
447233
def handle_errors(resp):
    """"""
    if resp.status_code == 400:
        raise ApiException(json.loads(resp.content).get('message'))
    return resp
344398
def _from_gerror(cls, error, own=True):
        """"""

        if not own:
            error = error.copy()

        self = cls()
        self._error = error
        return self
184170
def error(self, msg, repeat_at_end=True):
        """"""
        print(msg, file=sys.stderr)
        if repeat_at_end:
            self.error_log.append(msg)
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
1294097
def format_error(self, error, args=None):
        
        if type(args) is dict:
            return error.format(**args)
        if type(args) is list or type(args) is tuple:
            return error.format(*args)

        return error