/*
SError is like VError, but stricter about types.  You cannot pass "null" or
"undefined" as string arguments to the formatter.
961259
function SError()
{
	var args, obj, parsed, options;

	args = Array.prototype.slice.call(arguments, 0);
	if (!(this instanceof SError)) {
		obj = Object.create(SError.prototype);
		SError.apply(obj, arguments);
		return (obj);
	}

	parsed = parseConstructorArguments({
	    'argv': args,
	    'strict': true
	});

	options = parsed.options;
	VError.call(this, options, '%s', parsed.shortmessage);

	return (this);
}
1369312
function valueIsNullForValidator(value, validatorName) {
  if (value === null || value === CONSTANT.NULL || typeof value === 'undefined') {
    return true;
  }

  if (value === '' && VALIDATOR_CONSIDERS_EMPTY_STRING_NULL[validatorName]) {
    return true;
  }

  return false;
}
1327846
function (type, error = null, id = null) {
    type = type.toUpperCase()
    let errors = {
        'NO_DATA': 'No info for that id yet. Or maybe the data provided was wrong.',
        'BUSY': 'The server providing the info is busy right now. Try again.',
        'UNAVAILABLE': 'The server providing the info is unavailable right now. Try again later.',
        'EMPTY': 'The provider server was parsed correctly, but has no data to show. Try Again later.',
        'DOWN': 'The provider server is currently down. Try Again later.',
        'PARSER': 'Something went wrong when parsing the provider website.',
        'ACTION_REQUIRED': 'That tracker requires an aditional step in their website.'
    }

    let message = error != null ? error : errors[type]
    message = id != null ? message + ' ID:' + id : message
    return new Error(type + ' - ' + message)
}
563920
function sendError(req, res, err) {
        return res.end("(" + function (err) {
            throw new Error(err)
        } + "(" + JSON.stringify(err.message) + "))")
    }
311020
function rejectOnError(response, url) {
	const error = new Error(`${response.statusText} - status=${response.status}`);

	error.url = url;
	error.status = response.status;
	error.response = response.clone();

	debug( d => response.clone().text( text =>  d(`Response Error - url=${url}, text=${ text }`, response) ) );

	if (response.status === 422) {
		return response.json()
			.then( data => {
				error.validationErrors = data;

				throw error;
			})

		} else {
			return Store.reject(error);
		}
}
981882
function(){
            if(errors.length) return cb(errors);
            var transform = opts.transform || function(_result, _cb){
              _cb(null, _result);
            };
            transform(result, function(err, _result){
              if(err){
                errors.push(formatError(err, key));
                cb(errors);
              }else{
                cb(null, _result);
              }
            });
          }
1059032
function formatError(e) {
  if (!e.err) return e.message;
  if (e.err.message) return e.err.message;
  return JSON.stringify(e.err);
}
1023274
function serializeError(err) {
  var o = {};

  Object.getOwnPropertyNames(err).forEach(function (k) {
    o[k] = err[k];
  });

  return _.omit(o, ['stack', 'type', 'arguments']);
}
845930
function (content) {
            // Convert bad values into empty strings
            var isInvalid = content === null || content === undefined || (isNaN(content) && ("" + content === 'NaN'));
            return ("" + (isInvalid ? '' : content)).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(strQuote, '&#34;').replace(strSingleQuote, "&#39;");
        }
617826
public static void sendError( String messageKey, Object[] messageArgs, ServletRequest request,
                                  ServletResponse response, Throwable cause, boolean avoidDirectResponseOutput )
            throws IOException
    {
        assert messageArgs.length == 0 || ! ( messageArgs[0] instanceof Object[] )
                : "Object[] passed to sendError; this is probably a mistaken use of varargs";

        // request may be null because of deprecated FlowController.sendError().
        if ( request != null && avoidDirectResponseOutput )
        {
            String baseMessage = Bundle.getString( messageKey + "_Message", messageArgs );
            throw new ResponseOutputException( baseMessage, cause );
        }

        // Filter the message args to prevent cross-site scripting (XSS) attacks (e.g., if one of the args is something
        // that ultimately came from the user request, and it contains something like <script>[some sscript]</script>.
        for (int i = 0; i < messageArgs.length; i++) {
            Object messageArg = messageArgs[i];
            messageArgs[i] = messageArg != null ? filterValue(messageArg.toString()) : null;
        }
        
        String html = Bundle.getString( messageKey + "_Page", messageArgs );
        response.setContentType( "text/html;charset=UTF-8" );
        response.getWriter().println(html);
        ServletUtils.preventCache( response );
    }
646348
function (type) {
      var error = Exception.errors.filter(function (item) {
        return item.type === type || item.output === type;
      })[0];

      return error ? error.output : null;
    }
1210256
function _formatErrorsWarnings(level, list, projectRoot){
    return list.map(x => {
        let file, line, col, endLine, endCol, message
        try{
            // resolve  the relative path 
            let fullFilePath = data_get(x, 'module.resource')
            file = fullFilePath && projectRoot ? path.relative(projectRoot, fullFilePath) : ''
            // file = file.replace(/[\\//]/g, '/')

            line = data_get(x, 'error.error.loc.line') || 0
            col = data_get(x, 'error.error.loc.column') || 0

            // only need first line of message
            let fullMessage = (x.message + '').trim()
            let crPos = fullMessage.indexOf("\n")
            if (crPos >= 0){
                message = fullMessage.substring(0, crPos)
            } else {
                message = fullMessage
            }

            if (!line){
                let linesColsInfo
                let m
                if (x.name === 'ModuleNotFoundError'
                    && (m = fullMessage.match(MODULE_NOT_FOUND_ERR_MSG_PATTERN))){
                    linesColsInfo = _resolveLineColNumInFile(fullFilePath, m[1])
                } else if (fullMessage.indexOf('component lists rendered with v-for should have explicit keys') > 0
                    && (m = fullMessage.match(/([a-zA-Z-_]+)\s+(v-for=['"].*?['"])/))){
                    linesColsInfo = _resolveLineColNumInFile(fullFilePath, m[2], {after: m[1]})
                } else if (m = fullMessage.match(/export ['"](\S+?)['"] was not found/)){
                    linesColsInfo = _resolveLineColNumInFile(fullFilePath, m[1], {after: 'import'})
                } else if (m = fullMessage.match(/Error compiling template:((?:.|[\r\n])*)- Component template/m)){
                    linesColsInfo = _resolveLineColNumInFile(fullFilePath, m[1].trim())
                    message = fullMessage.replace(/\n/g, ' ')
                }

                if (linesColsInfo){
                    line = linesColsInfo.line || 0
                    col = linesColsInfo.col || 0
                    endLine = linesColsInfo.endLine
                    endCol = linesColsInfo.endCol
                }
            }

            let endLinesCols = (endLine || endCol) ? ('~' + (endLine || '') + (endLine ? ',' : '') + (endCol || '0')) : ''

            return `!>${level}: ${file}:${line},${col}${endLinesCols}: ${message || '@see output window'}`            
        } catch (e){
            console.warn(e)
            return ''
        }
    }).join("\n")
}
95014
public void error(String format, Object... args) throws IOException, ServletException {
        error(String.format(format,args));
    }
1265954
function _onError(event, error, msgData) {
        var message;

        // Sometimes error.message is undefined
        if (!error.message) {
            console.warn("Expected a non-empty string in error.message, got this instead:", error.message);
            message = JSON.stringify(error);
        } else {
            message = error.message;
        }

        // Remove "Uncaught" from the beginning to avoid the inspector popping up
        if (message && message.substr(0, 8) === "Uncaught") {
            message = message.substr(9);
        }

        // Additional information, like exactly which parameter could not be processed.
        var data = error.data;
        if (Array.isArray(data)) {
            message += "\n" + data.join("\n");
        }

        // Show the message, but include the error object for further information (e.g. error code)
        console.error(message, error, msgData);
    }
700013
function RequestError(err, url) {
	VError.call(this, err, 'for url %s', url);
	this.name = RequestError.name;
}
1344891
function errHandler(err, req, res, next) {
  console.log(addTimestamp("Internal error: " + util.inspect(err)));
  console.error(addTimestamp("Internal error: " + util.inspect(err)));
  if (err && err.stack) {
    console.error(err.stack);
  }

  var errorMessage = {
    msg: 'Internal error: ' + util.inspect(err),
    error: util.inspect(err)
  };
  if (res) {
    res.statusCode = 500;
    res.end(JSON.stringify(errorMessage));
  }

  return errorMessage;
}
305361
function handleErrors(errorFormatter, response) {
  if (!response.ok) {
    if (errorFormatter) {
      return errorFormatter(response);
    }

    return defaultErrorFormatter(response);
  }
  return response;
}