Given a utf8 message string, create an Exception object.
189386
def extern_create_exception(self, context_handle, msg_ptr, msg_len):
    """"""
    c = self._ffi.from_handle(context_handle)
    msg = self.to_py_str(msg_ptr, msg_len)
    return c.to_value(Exception(msg))
409159
protected function _createStringTranslationException($message, $code = 0, \Exception $previous = null, $subject = null, TranslatorInterface $translator = null, $context = null)
    {
        return new StringTranslationException($message, $code, $previous, $subject, $translator, $context);
    }
326422
def extract_error_message(cls, e):
        """"""
        message = str(e)
        try:
            if isinstance(e.args, tuple) and len(e.args) > 1:
                message = e.args[1]
        except Exception:
            pass
        return message
753991
def handle_exception(self, message, exc):
        # type: (Text, Exception) -> Any
        
        return self.handle_invalid_value(
            message     = message,
            exc_info    = True,
            context     = getattr(exc, 'context', {}),
        )
755269
def from_exception(exc, uuid=None):
        
        if not isinstance(exc, Error):
            exc = Error(code=500, message=str(exc))

        return Result(
            uuid=exc.extra.get("uuid", uuid or random_uuid()),
            retcode=exc.code, stderr=exc.message,
            retval=dict(error=ErrorSchema().dump(exc))
        )
1066504
public void exception(CharSequence message, Throwable e) {
    log(Level.SEVERE, message, e);
  }
1220876
def encode_exception(exception):
    
    import sys
    return AsyncException(unicode(exception),
                          exception.args,
                          sys.exc_info(),
                          exception)
1141230
def any2utf8(text, errors='strict', encoding='utf8'):
    """"""
    if isinstance(text, unicode):
        return text.encode('utf8')
    # do bytestring -> unicode -> utf8 full circle, to ensure valid utf8
    return unicode(text, encoding, errors=errors).encode('utf8')
34863
def _raise_exception(self, eobj, edata=None):
        """"""
        _, _, tbobj = sys.exc_info()
        if edata:
            emsg = self._format_msg(eobj["msg"], edata)
            _rwtb(eobj["type"], emsg, tbobj)
        else:
            _rwtb(eobj["type"], eobj["msg"], tbobj)
541749
def exception_message():
    """"""
    exc_type, exc_value, exc_tb = exc_info = sys.exc_info()
    return {'exception': {'type': exc_type,
                          'value': exc_value,
                          'traceback': exc_tb},
            'traceback': traceback.format_exception(*exc_info)}
475871
def get_charset(message, default='ASCII'):
    """"""

    charset = message.get_content_charset()

    if not charset:
        charset = message.get_charset()

    if not charset:
        charset = default

    try:
        codecs.lookup(charset)
    except LookupError:
        charset = default

    return charset
614974
private String getMessage(boolean localized) {
        String msg = localized ? super.getLocalizedMessage() : super.getMessage();
        StringBuilder sb = new StringBuilder(msg == null ? "" : msg);
        
        for (Throwable exception : exceptions) {
            msg = localized ? exception.getLocalizedMessage() : exception.getMessage();
            
            if (msg != null) {
                sb.append(sb.length() == 0 ? "" : "\n\n").append(msg);
            }
        }
        
        return sb.toString();
    }
1335908
def utf8(string):
    
    if isinstance(string, six.text_type):
        return string.encode('utf8')
    elif isinstance(string, six.binary_type):
        return string
    else:
        return six.text_type(string).encode('utf8')
571301
public static String exception2StringShort(Exception e) {
        StringBuffer st = new StringBuffer();
        Throwable e2 = e;

        while (e2 != null) {
            String exClass = e2.getClass().getName();
            String msg = e2.getMessage();

            if (msg != null) {
                st.setLength(0);
                st.append(exClass);
                st.append(": ");
                st.append(msg);
            }
            e2 = e2.getCause();
        }

        return st.toString().trim();
    }
974292
def get_charset(message, default="utf-8"):
    """"""
    if message.get_content_charset():
        return message.get_content_charset()
    if message.get_charset():
        return message.get_charset()
    return default
1338394
function createInvalidExceptionError(message, value) {
  var err = new Error(message);
  err.code = 'ERR_MOCHA_INVALID_EXCEPTION';
  err.valueType = typeof value;
  err.value = value;
  return err;
}
858908
public static String createErrorMessage(HttpException exception) {
    String json = tryParseAsJsonError(exception.content());
    if (json != null) {
      return json;
    }

    String msg = "HTTP code " + exception.code();
    if (isHtml(exception.content())) {
      return msg;
    }

    return msg + ": " + StringUtils.left(exception.content(), MAX_ERROR_MSG_LEN);
  }