public static void addErrorMessageToContext(final MessageContext messageContext, final String code,
                                                final String defaultText, final Object[] args) {
        val msg = new MessageBuilder()
            .error()
            .code(code)
            .args(args)
            .defaultText(defaultText)
            .build();
        messageContext.addMessage(msg);
    }
Add error message to context.

@param messageContext the message context
@param code           the code
@param defaultText    the default text
@param args           the args
core/cas-server-core-web-api/src/main/java/org/apereo/cas/web/support/WebUtils.java