构造错误

@param mvc   mvc
@param error 错误

@return mvc
181931
@SuppressWarnings("rawtypes")
    private ModelAndView buildError(ModelAndView mvc, ResultCode error) {
        mvc.addObject("data", new ArrayList(0));
        mvc.addObject("status", error.getCode());
        Map<String, Object> statusInfo = Maps.newHashMapWithExpectedSize(1);
        statusInfo.put(WebResponseConstant.MESSAGE_GLOBAL, error.getMessage().getMessage());
        mvc.addObject("statusInfo", statusInfo);
        mvc.addObject("msg", error.getMessage().getMessage());
        return mvc;
    }
427896
function InvalidModelError(boundPath, shortedPath) {
    var instance = new Error("The boundPath of the model is not valid since a value or error was found before the path end.");

    instance.name = "InvalidModelError";
    instance.boundPath = boundPath;
    instance.shortedPath = shortedPath;

    if (Object.setPrototypeOf) {
        Object.setPrototypeOf(instance, Object.getPrototypeOf(this));
    }

    if (Error.captureStackTrace) {
        Error.captureStackTrace(instance, InvalidModelError);
    }

    return instance;
}
695738
public Javalin error(int statusCode, @NotNull ErrorHandler errorHandler) {
        servlet.getErrorMapper().getErrorHandlerMap().put(statusCode, errorHandler);
        return this;
    }
1320937
public static <T, X extends Throwable> Try<T, X> failure(final X error) {
        return new Try<>(Either.left(
            error),new Class[0]);
    }
62867
function error (message, error) {
    // build custom error message
    message = `${this.model.name}#${this.id} record error` + (
        typeof message === 'string'
            ? `: ${message}`
            : ''
    )
    // use error object passed in
    if (defined(error)) {
        // create data object with original message
        error.data = {
            message: error.message,
        }
    }
    // create new error message
    else {
        error = new Error(message)
        error.data = {}
    }
    // set record data for error
    error.data.record = this

    return error
}
1325984
public static function loadFromModel(&$src, $model, &$error)
    {
        if ( !is_array($src) ) {
            $error = '数据模型格式错误';
            return false;
        }
        $data = array();
        foreach ( $src as $key => $value ) {
            if ( is_array($model[$key]) ) {
                //过滤数据
                $result = self::check($value, $model[$key], $error);

                if ( $result === false ) {
                    return false;
                }

                //存储过滤后的数据
                $data[$key] = $result;

            } else {
                $data[$key] = $value;
            }
        }

        return $data;
    }
747281
@RequestMapping("VIEW")
    public String renderError(RenderRequest request, RenderResponse response, ModelMap model)
            throws Exception {

        HttpServletRequest httpRequest = this.portalRequestUtils.getPortletHttpRequest(request);
        IPortletWindowId currentFailedPortletWindowId =
                (IPortletWindowId)
                        request.getAttribute(REQUEST_ATTRIBUTE__CURRENT_FAILED_PORTLET_WINDOW_ID);
        model.addAttribute("portletWindowId", currentFailedPortletWindowId);
        Exception cause =
                (Exception) request.getAttribute(REQUEST_ATTRIBUTE__CURRENT_EXCEPTION_CAUSE);
        model.addAttribute("exception", cause);
        final String rootCauseMessage = ExceptionUtils.getRootCauseMessage(cause);
        model.addAttribute("rootCauseMessage", rootCauseMessage);

        // Maintenance Mode?
        if (cause != null && cause instanceof MaintenanceModeException) {
            return "/jsp/PortletError/maintenance";
        }

        IUserInstance userInstance = this.userInstanceManager.getUserInstance(httpRequest);
        if (hasAdminPrivileges(userInstance)) {
            IPortletWindow window =
                    this.portletWindowRegistry.getPortletWindow(
                            httpRequest, currentFailedPortletWindowId);
            window.setRenderParameters(new ParameterMap());
            IPortalUrlBuilder adminRetryUrl =
                    this.portalUrlProvider.getPortalUrlBuilderByPortletWindow(
                            httpRequest, currentFailedPortletWindowId, UrlType.RENDER);
            model.addAttribute("adminRetryUrl", adminRetryUrl.getUrlString());

            final IPortletWindow portletWindow =
                    portletWindowRegistry.getPortletWindow(
                            httpRequest, currentFailedPortletWindowId);
            final IPortletEntity parentPortletEntity = portletWindow.getPortletEntity();
            final IPortletDefinition parentPortletDefinition =
                    parentPortletEntity.getPortletDefinition();
            model.addAttribute("channelDefinition", parentPortletDefinition);

            StringWriter stackTraceWriter = new StringWriter();
            cause.printStackTrace(new PrintWriter(stackTraceWriter));

            model.addAttribute("stackTrace", stackTraceWriter.toString());

            return "/jsp/PortletError/detailed";
        }
        // no admin privileges, return generic view
        return "/jsp/PortletError/generic";
    }
504714
public static String getError(final HttpServletRequest request) {
		StringBuilder sb = (StringBuilder) request.getAttribute(ERROR_KEY);
		if (sb == null) {
			return "";
		}
		return sb.toString();
	}
68461
@SuppressWarnings({"ThrowableInstanceNeverThrown"})
    public static HttpResponseException error(int code, String errorMessage) {
        return error(code,new Exception(errorMessage));
    }
248803
public String getErrorPage(String error)
    {
        if (_errorPages == null)
            return null;
        return (String)_errorPages.get(error);
    }
1158898
function defaultErrorHandler(jqXHR, textStatus, errorThrown) {
    var result = {
        status: REQUEST_FAIL_STATUS,
        statusInfo: {
            message: '服务器正忙...请稍后再试',
            detail: {
                httpStatus: jqXHR.status,
                textStatus: textStatus,
                errorThrown: errorThrown,
                xhr: jqXHR
            }
        }
    };

    commonErrorStatusHandler.call(this, result);
    return $.Deferred().reject(result).promise();
}
323423
private ModelAndView generateErrorView(final String code, final Object[] args, final HttpServletRequest request, final WebApplicationService service) {
        val modelAndView = serviceValidateConfigurationContext.getValidationViewFactory().getModelAndView(request, false, service, getClass());
        val convertedDescription = this.applicationContext.getMessage(code, args, code, request.getLocale());
        modelAndView.addObject(CasViewConstants.MODEL_ATTRIBUTE_NAME_ERROR_CODE, StringEscapeUtils.escapeHtml4(code));
        modelAndView.addObject(CasViewConstants.MODEL_ATTRIBUTE_NAME_ERROR_DESCRIPTION, StringEscapeUtils.escapeHtml4(convertedDescription));
        return modelAndView;
    }
939638
@Override
    public ScopedMessageHandler errors() {
        if (errorsHandler == null) {
            synchronized (this) {
                if (errorsHandler == null) {
                    errorsHandler = createScopedMessageHandler(getErrorMessagesKey());
                }
            }
        }
        return errorsHandler;
    }
335140
public Collection<Exception> error(final Object message, final Throwable error) {
        return Lists.reverse(errorHandlers).stream()
                .flatMap(f -> f.apply(message, error).map(Stream::of).orElse(Stream.empty()))
                .collect(Collectors.toList());
    }
757359
@SuppressWarnings("unchecked")
    protected JsonObject paramError(Map<String, Object> errors) {
        JsonObject json = JsonObject.create();
        json.setStatus(GlobalResponseStatusMsg.SYSTEM_ERROR.getMessage().getCode());
        Map<String, Object> error = new HashMap<String, Object>();
        error.put(WebResponseConstant.MESSAGE_FIELD, errors);
        json.setStatusInfo(error);
        return json;
    }
1264762
private ModelAndView buildBizErrors(TypeMismatchException e, ModelAndView model) {
        Throwable t = e.getCause();
        if (t instanceof ConversionFailedException) {
            ConversionFailedException x = (ConversionFailedException) t;
            TypeDescriptor type = x.getTargetType();
            Annotation[] annotations = type != null ? type.getAnnotations() : new Annotation[0];
            Map<String, Object> errors = new HashMap<String, Object>();
            for (Annotation a : annotations) {
                if (a instanceof RequestParam) {
                    errors.put(((RequestParam) a).value(), GlobalResponseStatusMsg.PARAM_TYPE_ERROR
                            .getMessage().getMessage());
                }
            }
            if (errors.size() > 0) {
                return buildBizError(model, errors);
            }
        }

        return buildError(model, GlobalResponseStatusMsg.PARAM_TYPE_ERROR);
    }
1174846
private String getMessage(Object error) {
        if (error instanceof Throwable) {
            String message = ((Throwable) error).getMessage();

            if (message == null) {
                if (fullStack) {
                    message = error.getClass().getName();
                }
            }

            return message;
        } else if (error instanceof String) {
            return (String) error;
        } else if (error instanceof Integer) {
            return HttpResponseStatus.valueOf((Integer) error).reasonPhrase();
        } else if (error instanceof JsonObject) {
            return ((JsonObject) error).getString("message");
        } else if (error instanceof Map) {
            return (String) ((Map) error).get("message");
        } else {
            return error.toString();
        }
    }