public _ErrorDescriptionBuilder tip(String tip) { tip((Object) tip); return this; }
errDescBuilder.tips(TIP_JSP_TAGLIBS, TIP); } else { errDescBuilder.tip(TIP);
public _ErrorDescriptionBuilder tip(Object... tip) { tip((Object) tip); return this; }
/** * Used for assignments that use operators like {@code +=}, when the target variable was null/missing. */ static InvalidReferenceException getInstance(int scope, String missingAssignedVarName, String assignmentOperator, Environment env) { if (env != null && env.getFastInvalidReferenceExceptions()) { return FAST_INSTANCE; } else { final _ErrorDescriptionBuilder errDescBuilder = new _ErrorDescriptionBuilder( "The target variable of the assignment, ", new _DelayedJQuote(missingAssignedVarName), ", was null or missing in the " + Assignment.scopeAsString(scope) + ", and the \"", assignmentOperator, "\" operator must get its value from there before assigning to it." ); if (missingAssignedVarName.startsWith("$")) { errDescBuilder.tips(TIP_NO_DOLLAR, TIP_MISSING_ASSIGNMENT_TARGET); } else { errDescBuilder.tip(TIP_MISSING_ASSIGNMENT_TARGET); } return new InvalidReferenceException(errDescBuilder, env, null); } }
UnexpectedTypeException( Expression blamed, TemplateModel model, String expectedTypesDesc, Class[] expectedTypes, String tip, Environment env) throws InvalidReferenceException { super(null, env, blamed, newDesciptionBuilder(blamed, null, model, expectedTypesDesc, expectedTypes, env) .tip(tip)); }
edb.tip(SimpleMethodModel.MARKUP_OUTPUT_TO_STRING_TIP); return;
/** * @param blamedAssignmentTargetVarName * Used for assignments that use {@code +=} and such, in which case the {@code blamed} expression * parameter will be null {@code null} and this parameter will be non-{null}. */ private static _ErrorDescriptionBuilder newDesciptionBuilder( Expression blamed, String blamedAssignmentTargetVarName, TemplateModel model, String expectedTypesDesc, Class[] expectedTypes, Environment env) throws InvalidReferenceException { if (model == null) throw InvalidReferenceException.getInstance(blamed, env); _ErrorDescriptionBuilder errorDescBuilder = new _ErrorDescriptionBuilder( unexpectedTypeErrorDescription(expectedTypesDesc, blamed, blamedAssignmentTargetVarName, model)) .blame(blamed).showBlamer(true); if (model instanceof _UnexpectedTypeErrorExplainerTemplateModel) { Object[] tip = ((_UnexpectedTypeErrorExplainerTemplateModel) model).explainTypeError(expectedTypes); if (tip != null) { errorDescBuilder.tip(tip); } } if (model instanceof TemplateCollectionModel && (Arrays.asList(expectedTypes).contains(TemplateSequenceModel.class) || Arrays.asList(expectedTypes).contains(TemplateCollectionModelEx.class))) { errorDescBuilder.tip("As the problematic value contains a collection of items, you could convert it " + "to a sequence like someValue?sequence. Be sure though that you won't have a large number of " + "items, as all will be held in memory one the same time."); } return errorDescBuilder; }
protected void checkDateTypeNotUnknown(int dateType) throws TemplateException { if (dateType == TemplateDateModel.UNKNOWN) { throw new _MiscTemplateException(new _ErrorDescriptionBuilder( "The value of the following has unknown date type, but ?", key, " needs a value where it's known if it's a date (no time part), time, or date-time value:" ).blame(target).tip(_MessageUtil.UNKNOWN_DATE_TYPE_ERROR_TIP)); } }
private TemplateModelException createArgumentTypeMismarchException( int argIdx, TemplateModel argVal, Class targetType) { _ErrorDescriptionBuilder desc = new _ErrorDescriptionBuilder( _MethodUtil.invocationErrorMessageStart(member), " couldn't be called: Can't convert the ", new _DelayedOrdinal(Integer.valueOf(argIdx + 1)), " argument's value to the target Java type, ", ClassUtil.getShortClassName(targetType), ". The type of the actual value was: ", new _DelayedFTLTypeDescription(argVal)); if (argVal instanceof TemplateMarkupOutputModel && (targetType.isAssignableFrom(String.class))) { desc.tip(MARKUP_OUTPUT_TO_STRING_TIP); } return new _TemplateModelException(desc); }
if (e instanceof IllegalArgumentException && !(setterType.isAssignableFrom(String.class)) && argArray[0] != null && argArray[0] instanceof String) { desc.tip("This problem is often caused by unnecessary parameter quotation. Paramters " + "aren't quoted in FTL, similarly as they aren't quoted in most languages. " + "For example, these parameter assignments are wrong: ",
desc.tip("Only adapted Java objects can possibly have API, not values created inside templates."); } else { ObjectWrapper ow = env.getObjectWrapper(); DefaultObjectWrapper dow = (DefaultObjectWrapper) ow; if (!dow.getUseAdaptersForContainers()) { desc.tip("In the FreeMarker configuration, \"", Configurable.OBJECT_WRAPPER_KEY, "\" is a DefaultObjectWrapper with its \"useAdaptersForContainers\" property set to " + "false. Setting it to true might solves this problem."); if (dow.getIncompatibleImprovements().intValue() < _TemplateAPI.VERSION_INT_2_3_22) { desc.tip("Setting DefaultObjectWrapper's \"incompatibleImprovements\" to 2.3.22 or higher will " + "change the default value of \"useAdaptersForContainers\" to true."); desc.tip("In the FreeMarker configuration, \"", Configurable.OBJECT_WRAPPER_KEY, "\" is a DefaultObjectWrapper with its \"forceLegacyNonListCollections\" property set "
private static String ensureFormatResultString(Object formatResult, Expression exp, Environment env) throws NonStringException { if (formatResult instanceof String) { return (String) formatResult; } assertFormatResultNotNull(formatResult); TemplateMarkupOutputModel mo = (TemplateMarkupOutputModel) formatResult; _ErrorDescriptionBuilder desc = new _ErrorDescriptionBuilder( "Value was formatted to convert it to string, but the result was markup of ouput format ", new _DelayedJQuote(mo.getOutputFormat()), ".") .tip("Use value?string to force formatting to plain text.") .blame(exp); throw new NonStringException(null, desc); }
public static TemplateModelException newKeyValuePairListingNonStringKeyExceptionMessage( TemplateModel key, TemplateHashModelEx listedHashEx) { return new _TemplateModelException(new _ErrorDescriptionBuilder( "When listing key-value pairs of traditional hash " + "implementations, all keys must be strings, but one of them " + "was ", new _DelayedAOrAn(new _DelayedFTLTypeDescription(key)), "." ).tip("The listed value's TemplateModel class was ", new _DelayedShortClassName(listedHashEx.getClass()), ", which doesn't implement ", new _DelayedShortClassName(TemplateHashModelEx2.class), ", which leads to this restriction.")); }
memberListToString()); if (!bugfixed) { edb.tip("You seem to use BeansWrapper with incompatibleImprovements set below 2.3.21. If you think this " + "error is unfounded, enabling 2.3.21 fixes may helps. See version history for more.");
? "specified, but had null/missing value." : "not specified.") ).tip(argWasSpecified ? new Object[] { "If the parameter value expression on the caller side is known to "
UnexpectedTypeException( Expression blamed, TemplateModel model, String expectedTypesDesc, Class[] expectedTypes, String tip, Environment env) throws InvalidReferenceException { super(null, env, blamed, newDesciptionBuilder(blamed, null, model, expectedTypesDesc, expectedTypes, env) .tip(tip)); }
UnexpectedTypeException( Expression blamed, TemplateModel model, String expectedTypesDesc, Class[] expectedTypes, String tip, Environment env) throws InvalidReferenceException { super(null, env, blamed, newDesciptionBuilder(blamed, null, model, expectedTypesDesc, expectedTypes, env) .tip(tip)); }
protected void checkDateTypeNotUnknown(int dateType) throws TemplateException { if (dateType == TemplateDateModel.UNKNOWN) { throw new _MiscTemplateException(new _ErrorDescriptionBuilder( "The value of the following has unknown date type, but ?", key, " needs a value where it's known if it's a date (no time part), time, or date-time value:" ).blame(target).tip(_MessageUtil.UNKNOWN_DATE_TYPE_ERROR_TIP)); } }
protected void checkDateTypeNotUnknown(int dateType) throws TemplateException { if (dateType == TemplateDateModel.UNKNOWN) { throw new _MiscTemplateException(new _ErrorDescriptionBuilder( "The value of the following has unknown date type, but ?", key, " needs a value where it's known if it's a date (no time part), time, or date-time value:" ).blame(target).tip(_MessageUtil.UNKNOWN_DATE_TYPE_ERROR_TIP)); } }
private TemplateModelException createArgumentTypeMismarchException( int argIdx, TemplateModel argVal, Class targetType) { _ErrorDescriptionBuilder desc = new _ErrorDescriptionBuilder( _MethodUtil.invocationErrorMessageStart(member), " couldn't be called: Can't convert the ", new _DelayedOrdinal(Integer.valueOf(argIdx + 1)), " argument's value to the target Java type, ", ClassUtil.getShortClassName(targetType), ". The type of the actual value was: ", new _DelayedFTLTypeDescription(argVal)); if (argVal instanceof TemplateMarkupOutputModel && (targetType.isAssignableFrom(String.class))) { desc.tip(MARKUP_OUTPUT_TO_STRING_TIP); } return new _TemplateModelException(desc); }