Generate message for exception.
967544
def _get_contract_exception_dict(contract_msg):
    """"""
    # A pcontract-defined custom exception message is wrapped in a string
    # that starts with '[START CONTRACT MSG:' and ends with
    # '[STOP CONTRACT MSG]'. This is done to easily detect if an
    # exception raised is from a custom contract and thus be able
    # to easily retrieve the actual exception message
    start_token = "[START CONTRACT MSG: "
    stop_token = "[STOP CONTRACT MSG]"
    # No custom contract
    if contract_msg.find(start_token) == -1:
        return {
            "num": 0,
            "msg": "Argument `*[argument_name]*` is not valid",
            "type": RuntimeError,
            "field": "argument_name",
        }
    # Custom contract
    msg_start = contract_msg.find(start_token) + len(start_token)
    contract_msg = contract_msg[msg_start:]
    contract_name = contract_msg[: contract_msg.find("]")]
    contract_msg = contract_msg[
        contract_msg.find("]") + 1 : contract_msg.find(stop_token)
    ]
    exdict = _CUSTOM_CONTRACTS[contract_name]
    for exvalue in exdict.values():  # pragma: no branch
        if exvalue["msg"] == contract_msg:
            return exvalue
895288
def exception_message(self) -> Union[str, None]:
        
        if self.has_error:
            exception_data = self._raw.get("exception", {})
            return exception_data.get("message")
        return None
755138
def fromMessage(cls, message):
        """"""
        error_text = message.getArg(
            OPENID_NS, 'error', '<no error message supplied>')
        error_code = message.getArg(OPENID_NS, 'error_code')
        return cls(error_text, error_code, message)
802094
def process_exception(self, request, exception):
        """"""
        log_format = self._get_log_format(request)
        if log_format is None:
            return

        params = self._get_parameters_from_request(request, True)
        params['message'] = exception
        params['http_status'] = '-'

        self.OPERATION_LOG.info(log_format, params)
760975
def raise_error(
            self,
            exception_type,  # type: Type[Exception]
            message  # type: Text
    ):
        # type: (...) -> NoReturn
        """"""
        error_message = '{} at {}'.format(message, repr(self))
        raise exception_type(error_message)
954043
def reformat_exception(cls, message, err, *format_args, **format_kwds):
        
        final_message = message.format(*format_args, **format_kwds)
        final_message = "{} -- {}: {}".format(
            final_message,
            type(err).__name__,
            str(err),
        )
        final_message = cls.sanitize_errstr(final_message)
        return final_message
697831
def _emit_error(cls, message):
        """"""
        sys.stderr.write('ERROR: {message}\n'.format(message=message))
        sys.stderr.flush()
267562
def get_exception():
    """"""
    trace = ""
    exception = ""
    exc_list = traceback.format_exception_only(
        sys.exc_info()[0], sys.exc_info()[1]
    )
    for entry in exc_list:
        exception += entry
    tb_list = traceback.format_tb(sys.exc_info()[2])
    for entry in tb_list:
        trace += entry
    return "%s\n%s" % (exception, trace)
521210
def exception_log_and_respond(exception, logger, message, status_code):
    """"""
    logger.error(message, exc_info=True)
    return make_response(
        message,
        status_code,
        dict(exception_type=type(exception).__name__, exception_message=str(exception)),
    )
501258
@JsonIgnore
    public String getErrorMessage() {
        return (params.length == 0) ? exceptionCode.getMessageTemplate() :
                String.format(exceptionCode.getMessageTemplate(), params);
    }
6770
def get_exception_error():
        ''' 
        '''
        error_message = ""
        for i in range(len(inspect.trace())):
            error_line = u"""
        File:      %s - [%s]
        Function:  %s
        Statement: %s
        -""" % (inspect.trace()[i][1], inspect.trace()[i][2], inspect.trace()[i][3], inspect.trace()[i][4])
            
            error_message = "%s%s" % (error_message, error_line)    
        
        error_message = u"""Error!\n%s\n\t%s\n\t%s\n-------------------------------------------------------------------------------------------\n\n""" % (error_message,sys.exc_info()[0], sys.exc_info()[1])
        
        return error_message
129145
def print_exception(self, msg):
        
        if self.exception_printed < 10:
            self.log.error(msg)
            self.exception_printed += 1
24631
def exception(self, *args, **kwargs):
        """"""
        return self._log_kw(ERROR, args, kwargs, exc_info=True)
479361
def process_exception_message(exception):
        
        exception_message = str(exception)
        for replace_char in ['\t', '\n', '\\n']:
            exception_message = exception_message.replace(replace_char, '' if replace_char != '\t' else ' ')
        return exception_message.replace('section', 'alias')
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
799573
def exc_message(exc_info):
    """"""
    exc = exc_info[1]
    if exc is None:
        # str exception
        result = exc_info[0]
    else:
        try:
            result = str(exc)
        except UnicodeEncodeError:
            try:
                result = unicode(exc)  # flake8: noqa
            except UnicodeError:
                # Fallback to args as neither str nor
                # unicode(Exception(u'\xe6')) work in Python < 2.6
                result = exc.args[0]
    return result
803400
private String getExceptionMessage(Throwable pException) {
        String message = pException.getLocalizedMessage();
        return pException.getClass().getName() + (message != null ? " : " + message : "");
    }