public static Object[] invocationErrorMessageStart(Member member) { return invocationErrorMessageStart(member, member instanceof Constructor); }
Object[] unwrapArguments(List arguments, BeansWrapper wrapper) throws TemplateModelException { if (arguments == null) { arguments = Collections.EMPTY_LIST; } boolean isVarArg = _MethodUtil.isVarargs(member); int typesLen = argTypes.length; if (isVarArg) { if (typesLen - 1 > arguments.size()) { throw new _TemplateModelException( _MethodUtil.invocationErrorMessageStart(member), " takes at least ", Integer.valueOf(typesLen - 1), typesLen - 1 == 1 ? " argument" : " arguments", ", but ", Integer.valueOf(arguments.size()), " was given."); } } else if (typesLen != arguments.size()) { throw new _TemplateModelException( _MethodUtil.invocationErrorMessageStart(member), " takes ", Integer.valueOf(typesLen), typesLen == 1 ? " argument" : " arguments", ", but ", Integer.valueOf(arguments.size()), " was given."); } Object[] args = unwrapArguments(arguments, argTypes, isVarArg, wrapper); return args; }
private static TemplateModelException newInvocationTemplateModelException( Object parentObject, Object member, boolean isStatic, boolean isConstructor, Throwable e) { while (e instanceof InvocationTargetException) { Throwable cause = ((InvocationTargetException) e).getTargetException(); if (cause != null) { e = cause; } else { break; } } return new _TemplateModelException(e, invocationErrorMessageStart(member, isConstructor), " threw an exception", isStatic || isConstructor ? (Object) "" : new Object[] { " when invoked on ", parentObject.getClass(), " object ", new _DelayedJQuote(parentObject) }, "; see cause exception in the Java stack trace."); }
private TemplateModelException createNullToPrimitiveArgumentException(int argIdx, Class targetType) { return new _TemplateModelException( _MethodUtil.invocationErrorMessageStart(member), " couldn't be called: The value of the ", new _DelayedOrdinal(Integer.valueOf(argIdx + 1)), " argument was null, but the target Java parameter type (", ClassUtil.getShortClassName(targetType), ") is primitive and so can't store null."); }
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); }
public static Object[] invocationErrorMessageStart(Member member) { return invocationErrorMessageStart(member, member instanceof Constructor); }
public static Object[] invocationErrorMessageStart(Member member) { return invocationErrorMessageStart(member, member instanceof Constructor); }
Object[] unwrapArguments(List arguments, BeansWrapper wrapper) throws TemplateModelException { if (arguments == null) { arguments = Collections.EMPTY_LIST; } boolean isVarArg = _MethodUtil.isVarargs(member); int typesLen = argTypes.length; if (isVarArg) { if (typesLen - 1 > arguments.size()) { throw new _TemplateModelException( _MethodUtil.invocationErrorMessageStart(member), " takes at least ", Integer.valueOf(typesLen - 1), typesLen - 1 == 1 ? " argument" : " arguments", ", but ", Integer.valueOf(arguments.size()), " was given."); } } else if (typesLen != arguments.size()) { throw new _TemplateModelException( _MethodUtil.invocationErrorMessageStart(member), " takes ", Integer.valueOf(typesLen), typesLen == 1 ? " argument" : " arguments", ", but ", Integer.valueOf(arguments.size()), " was given."); } Object[] args = unwrapArguments(arguments, argTypes, isVarArg, wrapper); return args; }
Object[] unwrapArguments(List arguments, BeansWrapper wrapper) throws TemplateModelException { if (arguments == null) { arguments = Collections.EMPTY_LIST; } boolean isVarArg = _MethodUtil.isVarargs(member); int typesLen = argTypes.length; if (isVarArg) { if (typesLen - 1 > arguments.size()) { throw new _TemplateModelException( _MethodUtil.invocationErrorMessageStart(member), " takes at least ", Integer.valueOf(typesLen - 1), typesLen - 1 == 1 ? " argument" : " arguments", ", but ", Integer.valueOf(arguments.size()), " was given."); } } else if (typesLen != arguments.size()) { throw new _TemplateModelException( _MethodUtil.invocationErrorMessageStart(member), " takes ", Integer.valueOf(typesLen), typesLen == 1 ? " argument" : " arguments", ", but ", Integer.valueOf(arguments.size()), " was given."); } Object[] args = unwrapArguments(arguments, argTypes, isVarArg, wrapper); return args; }
private static TemplateModelException newInvocationTemplateModelException( Object parentObject, Object member, boolean isStatic, boolean isConstructor, Throwable e) { while (e instanceof InvocationTargetException) { Throwable cause = ((InvocationTargetException) e).getTargetException(); if (cause != null) { e = cause; } else { break; } } return new _TemplateModelException(e, invocationErrorMessageStart(member, isConstructor), " threw an exception", isStatic || isConstructor ? (Object) "" : new Object[] { " when invoked on ", parentObject.getClass(), " object ", new _DelayedJQuote(parentObject) }, "; see cause exception in the Java stack trace."); }
private static TemplateModelException newInvocationTemplateModelException( Object parentObject, Object member, boolean isStatic, boolean isConstructor, Throwable e) { while (e instanceof InvocationTargetException) { Throwable cause = ((InvocationTargetException) e).getTargetException(); if (cause != null) { e = cause; } else { break; } } return new _TemplateModelException(e, invocationErrorMessageStart(member, isConstructor), " threw an exception", isStatic || isConstructor ? (Object) "" : new Object[] { " when invoked on ", parentObject.getClass(), " object ", new _DelayedJQuote(parentObject) }, "; see cause exception in the Java stack trace."); }
private TemplateModelException createNullToPrimitiveArgumentException(int argIdx, Class targetType) { return new _TemplateModelException( _MethodUtil.invocationErrorMessageStart(member), " couldn't be called: The value of the ", new _DelayedOrdinal(Integer.valueOf(argIdx + 1)), " argument was null, but the target Java parameter type (", ClassUtil.getShortClassName(targetType), ") is primitive and so can't store null."); }
private TemplateModelException createNullToPrimitiveArgumentException(int argIdx, Class targetType) { return new _TemplateModelException( _MethodUtil.invocationErrorMessageStart(member), " couldn't be called: The value of the ", new _DelayedOrdinal(Integer.valueOf(argIdx + 1)), " argument was null, but the target Java parameter type (", ClassUtil.getShortClassName(targetType), ") is primitive and so can't store null."); }
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); }
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); }