Package net.sourceforge.pmd.lang.ast
Class FileAnalysisException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- org.apache.commons.lang3.exception.ContextedRuntimeException
-
- net.sourceforge.pmd.lang.ast.FileAnalysisException
-
- All Implemented Interfaces:
Serializable
,org.apache.commons.lang3.exception.ExceptionContext
- Direct Known Subclasses:
LexException
,MalformedSourceException
,ParseException
,SemanticException
public class FileAnalysisException extends org.apache.commons.lang3.exception.ContextedRuntimeException
An exception that occurs while processing a file. Subtypes includeMalformedSourceException
: error in source format, eg invalid character escapes (in case that happens before lexing)LexException
: lexical syntax errorsParseException
: syntax errorsSemanticException
: exceptions occurring after the parsing phase, because the source code is semantically invalid
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description FileAnalysisException()
FileAnalysisException(String message)
FileAnalysisException(String message, Throwable cause)
FileAnalysisException(Throwable cause)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
errorKind()
@NonNull FileId
getFileId()
The name of the file in which the error occurred.String
getMessage()
protected boolean
hasFileName()
protected @Nullable FileLocation
location()
FileAnalysisException
setFileId(FileId fileId)
static FileAnalysisException
wrap(@NonNull FileId fileId, @NonNull String message, @NonNull Throwable cause)
Wraps the cause into an analysis exception.-
Methods inherited from class org.apache.commons.lang3.exception.ContextedRuntimeException
addContextValue, getContextEntries, getContextLabels, getContextValues, getFirstContextValue, getFormattedExceptionMessage, getRawMessage, setContextValue
-
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
-
-
-
Method Detail
-
setFileId
public FileAnalysisException setFileId(FileId fileId)
-
hasFileName
protected boolean hasFileName()
-
getFileId
public @NonNull FileId getFileId()
The name of the file in which the error occurred.
-
getMessage
public final String getMessage()
- Overrides:
getMessage
in classorg.apache.commons.lang3.exception.ContextedRuntimeException
-
errorKind
protected String errorKind()
-
location
protected @Nullable FileLocation location()
-
wrap
public static FileAnalysisException wrap(@NonNull FileId fileId, @NonNull String message, @NonNull Throwable cause)
Wraps the cause into an analysis exception. If it is itself an analysis exception, just returns it after setting the filename for context.- Parameters:
fileId
- Filenamemessage
- Context message, if the cause is not aFileAnalysisException
cause
- Exception to wrap- Returns:
- An exception
-
-