Package org.pkl.core.runtime
Class VmExceptionBuilder
- java.lang.Object
-
- org.pkl.core.runtime.VmExceptionBuilder
-
public class VmExceptionBuilder extends java.lang.ObjectError message guidelines:- Pkl strives to provide a great experience for casual users. Hence it must excel at error reporting.
- Be concrete and concise. Examples and explanations can help but must carry their weight.
- The source line is considered an integral part of the error message. Assume it's always presented to the user. Design the main message accordingly and avoid duplicated information.
- Use correct "natural language" spelling. Most messages should be sentences that start with an uppercase letter and end with a dot.
- The main message should typically be a single line and sentence. Try to make it both easy
to understand for novices and easy to recognize for experienced users. Use
withHint(java.lang.String)for longer explanations. - Don't include arbitrary-size information in the main message but instead use
withProgramValue(java.lang.String, java.lang.Object). - Use
withExternalMessage(java.lang.String, java.lang.Object...)whenever possible. - Avoid abbreviations (i.e., e.g., etc., ...). Some users will not be familiar with them.
- Use backticks for inline code (cf. Markdown). (For identifiers, *emphasis* may be preferable but isn't currently used. One problem with special formatting is that error output doesn't always go to a terminal and hence may be rendered verbatim.)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classVmExceptionBuilder.MultilineValue
-
Constructor Summary
Constructors Constructor Description VmExceptionBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description VmExceptionBuilderadhocEvalError(java.lang.String message, java.lang.Object... args)VmExceptionBuilderbug(java.lang.String message, java.lang.Object... args)VmExceptionbuild()VmExceptionBuildercannotFindKey(VmMap map, java.lang.Object key)VmExceptionBuildercannotFindMember(VmObjectLike receiver, java.lang.Object memberKey)VmExceptionBuildercannotFindMethod(VmObjectLike receiver, Identifier methodName, int arity, boolean isImplicitReceiver)VmExceptionBuildercannotFindProperty(VmObjectLike receiver, Identifier propertyName, boolean isRead, boolean isImplicitReceiver)VmExceptionBuilderevalError(java.lang.String messageKey, java.lang.Object... args)VmExceptionBuildertypeMismatch(java.lang.Object value, VmClass expectedType)VmExceptionBuildertypeMismatch(java.lang.Object value, VmClass expectedType1, VmClass expectedType2)VmExceptionBuilderundefinedPropertyValue(Identifier propertyName, java.lang.Object receiver)VmExceptionBuilderundefinedValue()VmExceptionBuilderunreachableCode()VmExceptionBuilderwithCause(java.lang.Throwable cause)VmExceptionBuilderwithHint(java.lang.String hint)VmExceptionBuilderwithLocation(com.oracle.truffle.api.nodes.Node location)VmExceptionBuilderwithMemberName(java.lang.String memberName)VmExceptionBuilderwithOptionalLocation(@Nullable com.oracle.truffle.api.nodes.Node location)VmExceptionBuilderwithProgramValue(java.lang.String name, java.lang.Object value)VmExceptionBuilderwithSourceSection(@Nullable com.oracle.truffle.api.source.SourceSection sourceSection)
-
-
-
Method Detail
-
typeMismatch
public VmExceptionBuilder typeMismatch(java.lang.Object value, VmClass expectedType)
-
typeMismatch
public VmExceptionBuilder typeMismatch(java.lang.Object value, VmClass expectedType1, VmClass expectedType2)
-
unreachableCode
public VmExceptionBuilder unreachableCode()
-
undefinedValue
public VmExceptionBuilder undefinedValue()
-
undefinedPropertyValue
public VmExceptionBuilder undefinedPropertyValue(Identifier propertyName, java.lang.Object receiver)
-
cannotFindMember
public VmExceptionBuilder cannotFindMember(VmObjectLike receiver, java.lang.Object memberKey)
-
cannotFindProperty
public VmExceptionBuilder cannotFindProperty(VmObjectLike receiver, Identifier propertyName, boolean isRead, boolean isImplicitReceiver)
-
cannotFindMethod
public VmExceptionBuilder cannotFindMethod(VmObjectLike receiver, Identifier methodName, int arity, boolean isImplicitReceiver)
-
cannotFindKey
public VmExceptionBuilder cannotFindKey(VmMap map, java.lang.Object key)
-
bug
public VmExceptionBuilder bug(java.lang.String message, java.lang.Object... args)
-
evalError
public VmExceptionBuilder evalError(java.lang.String messageKey, java.lang.Object... args)
-
adhocEvalError
public VmExceptionBuilder adhocEvalError(java.lang.String message, java.lang.Object... args)
-
withProgramValue
public VmExceptionBuilder withProgramValue(java.lang.String name, java.lang.Object value)
-
withLocation
public VmExceptionBuilder withLocation(com.oracle.truffle.api.nodes.Node location)
-
withOptionalLocation
public VmExceptionBuilder withOptionalLocation(@Nullable com.oracle.truffle.api.nodes.Node location)
-
withSourceSection
public VmExceptionBuilder withSourceSection(@Nullable com.oracle.truffle.api.source.SourceSection sourceSection)
-
withMemberName
public VmExceptionBuilder withMemberName(java.lang.String memberName)
-
withCause
public VmExceptionBuilder withCause(java.lang.Throwable cause)
-
withHint
public VmExceptionBuilder withHint(java.lang.String hint)
-
build
public VmException build()
-
-