Substitute parameters in exception message.
770663
def _format_msg(self, msg, edata):
        """"""
        edata = edata if isinstance(edata, list) else [edata]
        for fdict in edata:
            if "*[{token}]*".format(token=fdict["field"]) not in msg:
                raise RuntimeError(
                    "Field {token} not in exception message".format(
                        token=fdict["field"]
                    )
                )
            msg = msg.replace(
                "*[{token}]*".format(token=fdict["field"]), "{value}"
            ).format(value=fdict["value"])
        return msg
1220840
function createExceptionsPattern(exceptions) {
    let pattern = "";

    /*
     * A space or an exception pattern sequence.
     * []                 ==> "\s"
     * ["-"]              ==> "(?:\s|\-+$)"
     * ["-", "="]         ==> "(?:\s|(?:\-+|=+)$)"
     * ["-", "=", "--=="] ==> "(?:\s|(?:\-+|=+|(?:\-\-==)+)$)" ==> https://jex.im/regulex/#!embed=false&flags=&re=(%3F%3A%5Cs%7C(%3F%3A%5C-%2B%7C%3D%2B%7C(%3F%3A%5C-%5C-%3D%3D)%2B)%24)
     */
    if (exceptions.length === 0) {

        // a space.
        pattern += "\\s";
    } else {

        // a space or...
        pattern += "(?:\\s|";

        if (exceptions.length === 1) {

            // a sequence of the exception pattern.
            pattern += escapeAndRepeat(exceptions[0]);
        } else {

            // a sequence of one of the exception patterns.
            pattern += "(?:";
            pattern += exceptions.map(escapeAndRepeat).join("|");
            pattern += ")";
        }
        pattern += `(?:$|[${Array.from(astUtils.LINEBREAKS).join("")}]))`;
    }

    return pattern;
}
513589
def exception_to_signal(sig: Union[SignalException, signal.Signals]):
    
    if isinstance(sig, SignalException):
        signum = sig.signum
    else:
        signum = sig.value
    signal.signal(signum, signal.SIG_DFL)
1287659
def exception_wrapper(f):
    """"""
    @wraps(f)
    def wrapper(*args, **kwds):
        try:
            return f(*args, **kwds)
        except dbus.exceptions.DBusException as err:
            _args = err.args
            raise PyMPRISException(*_args)
    return wrapper
673307
def exception(message):
    """"""

    def decorator(method):
        """Inner decorator so we can accept arguments."""

        @wraps(method)
        def wrapper(self, *args, **kwargs):
            """Innermost decorator wrapper - this is confusing."""
            if self.messages:
                kwargs['message'] = args[0] if args else kwargs.get('message', message)
            else:
                kwargs['message'] = None
            kwargs['prefix'] = self.prefix
            kwargs['statsd'] = self.statsd

            return method(self, **kwargs)

        return wrapper

    return decorator
372057
protected String createExceptionMessage(Throwable exception, Request request, Response response)
    {
		StringBuilder sb = new StringBuilder(request.getEffectiveHttpMethod().toString());
		sb.append(' ');
		sb.append(request.getUrl());
		sb.append(" threw exception: ");
		sb.append(exception.getClass().getSimpleName());
		return sb.toString();
    }
511534
def exception(self):
        """"""
        buf = traceback.format_exception_only(self.exc_type, self.exc_value)
        rv = "".join(buf).strip()
        return to_unicode(rv, "utf-8", "replace")
308892
def translate_exception(exc, kwargs):
    
    error = exc.response['Error']
    error.setdefault('Message', '')
    err_class = EXC.get(error['Code'], DynamoDBError)
    return err_class(exc.response['ResponseMetadata']['HTTPStatusCode'],
                     exc_info=sys.exc_info(), args=pformat(kwargs), **error)
1175643
private String generateAbbreviatedExceptionMessage(final Throwable throwable) {

		final StringBuilder builder = new StringBuilder();
		builder.append(": ");
		builder.append(throwable.getClass().getCanonicalName());
		builder.append(": ");
		builder.append(throwable.getMessage());

		Throwable cause = throwable.getCause();
		while (cause != null) {
			builder.append('\n');
			builder.append("Caused by: ");
			builder.append(cause.getClass().getCanonicalName());
			builder.append(": ");
			builder.append(cause.getMessage());
			// make sure the exception cause is not itself to prevent infinite
			// looping
			assert (cause != cause.getCause());
			cause = (cause == cause.getCause() ? null : cause.getCause());
		}
		return builder.toString();
	}
611303
private String substitute(String uri) {
    	List<String> params = extractRequiredParamsInURI(uri);
    	for (String param: params) {
    		if (param.equals(PARAMS)) {
    			uri = uri.replace("{" + PARAMS +"}", Utils.urlEncode(getParamsURI()));
    		}
    		else {
    			uri = uri.replace("{" + param + "}", (String)commandParams.get(param));
    		}
    	}
        return uri;
    }
1111177
private String replaceParameters(String text) {
    	if (text == null) {
    		return null;
    	}
        for  (String param : parameterValues.keySet()) {
             text = StringUtil.replace(text, "\\$P\\{" + param + "\\}", StringUtil.getValueAsString(parameterValues.get(param), null,I18nUtil.getLanguageByName(chart, language)));
        }
        return text;
    }
1277688
def exception_handler(exceptionObj):
    """"""
    try:
        if isinstance(exceptionObj, Exception) and hasattr(exceptionObj, 'args'):
            if not (hasattr(exceptionObj, 'message' or hasattr(exceptionObj, 'msg'))):
                if len(exceptionObj.args) >= 1:
                    if type(exceptionObj.args[0]) == type(b''):
                        ob = json.loads(exceptionObj.args[0].decode('utf-8'))
                        if type(ob) == type({}) and ob['message']:
                            return ob['message']
                    else:

                        try:
                            if type(exceptionObj.args[0]) == type('') and exceptionObj.args[0][0] == 'b':
                                ob = json.loads(exceptionObj.args[0][2:-1])
                            else:
                                ob = json.loads(exceptionObj.args[0])
                            if type(ob) == type({}) and ob['message']:
                                try:
                                    return exception_handler(ob['message'])
                                except Exception as e:
                                    return ob['message']
                            elif type(ob) == type({}) and ob['msg']:
                                try:
                                    return exception_handler(ob['message'])
                                except Exception as e:
                                    return ob['msg']
                            return str(json.loads(exceptionObj.args[0]))
                        except Exception as e:
                            return str(exceptionObj.args[0])
            elif hasattr(exceptionObj, 'msg'):
                return exceptionObj.msg
            elif hasattr(exceptionObj, 'message'):
                return exceptionObj.message
        elif type(exceptionObj) == type(''):
            try:
                ob = json.loads(exceptionObj)
                if type(ob) == type({}):
                    if ob['message']:
                        return ob['message']
                    elif ob['msg']:
                        return ob['msg']
                    else:
                        return ob
            except Exception as e:
                return exceptionObj

    except Exception as e:
        return e
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
198107
def pformat(self, traceback=False):
        """"""
        buf = six.StringIO()
        if not self._exc_type_names:
            buf.write('Failure: %s' % (self._exception_str))
        else:
            buf.write('Failure: %s: %s' % (self._exc_type_names[0],
                                           self._exception_str))
        if traceback:
            if self._traceback_str is not None:
                traceback_str = self._traceback_str.rstrip()
            else:
                traceback_str = None
            if traceback_str:
                buf.write(os.linesep)
                buf.write(traceback_str)
            else:
                buf.write(os.linesep)
                buf.write('Traceback not available.')
        return buf.getvalue()
1077038
public static String substitute(String input, Object model)
    throws MdwException {
        return substitute(input, model, null, false);
    }
975995
private Exception updateErrorMsg(StringBuilder pErrors, Exception exp) {
        pErrors.append(exp.getClass()).append(": ").append(exp.getMessage()).append("\n");
        return exp;
    }
1247000
private static String toErrorItemMessage(final String logMessage, final String throwableMessage) {
		
		StringBuilder sb = new StringBuilder();
				
		if ((throwableMessage != null) && (!throwableMessage.isEmpty())) {
			sb.append(throwableMessage);
			
			if ((logMessage != null) && (!logMessage.isEmpty())) {
				sb.append(" (");
				sb.append(logMessage);
				sb.append(")");
			}			
		} else {
			sb.append(logMessage);
		}

		return sb.toString();
	}