public class ParseException
extends java.lang.Exception
Exceptions of this class can be thrown if an error occurs while parsing a file. It can be used for different file types.
Modifier and Type | Field and Description |
---|---|
private boolean |
causedByBlockCond |
private boolean |
causedByInvalidVar |
private java.io.File |
file |
private boolean |
isLastAdded |
private java.lang.String |
lineContent |
private int |
lineNumber |
private static long |
serialVersionUID |
private java.util.Deque<StackTraceElement> |
stackTrace |
Constructor and Description |
---|
ParseException()
Throws a generic parse exception without a detail message.
|
ParseException(java.lang.String message)
Throws an exception including a detail message.
|
Modifier and Type | Method and Description |
---|---|
private void |
addLastElementIfNotYetDone()
Adds the final element to the stack trace, if not yet done.
|
java.io.File |
getFile()
Returns the parsed file.
|
java.lang.String |
getFullMessage()
Returns the message including file name, line number, line content and/or stack trace, whatever is available.
|
java.lang.String |
getLineContent()
Returns the content of the line causing the exception.
|
int |
getLineNumber()
Returns the line number of the parsed file where the exception occured.
|
java.util.Deque<StackTraceElement> |
getStackTraceElements()
Returns a clone of the stack trace.
|
void |
setCausedByBlockConditions()
Marks this exeption as being caused by if/elsif/else conditions of a nestable block.
|
void |
setCausedByInvalidVar(java.lang.String varName)
Marks this exeption as being caused by an invalid variable or parameter name.
|
void |
setFile(java.io.File file)
Sets the parsed file.
|
void |
setLineContentIfNotYetDone(java.lang.String line)
Sets the content of the line that was parsed when the exception has been thrown, if not yet done.
|
void |
setLineNumber(int lineNumber)
Sets the line number of the parsed file where the exception occured.
|
void |
setStackTrace(java.util.Deque<StackTraceElement> stack)
Sets the given call stack.
|
private static final long serialVersionUID
private int lineNumber
private java.io.File file
private java.util.Deque<StackTraceElement> stackTrace
private java.lang.String lineContent
private boolean isLastAdded
private boolean causedByBlockCond
private boolean causedByInvalidVar
public ParseException()
Throws a generic parse exception without a detail message.
public ParseException(java.lang.String message)
Throws an exception including a detail message.
message
- public int getLineNumber()
Returns the line number of the parsed file where the exception occured.
public void setLineNumber(int lineNumber)
Sets the line number of the parsed file where the exception occured.
lineNumber
- Line number of the exception.public void setLineContentIfNotYetDone(java.lang.String line)
Sets the content of the line that was parsed when the exception has been thrown, if not yet done. If a line content is already set, this will not be overridden. This is the case if an exception occurs in an included file.
line
- MidicaPL line content.public java.lang.String getLineContent()
Returns the content of the line causing the exception.
This is only used for unit tests.
public void setCausedByBlockConditions()
Marks this exeption as being caused by if/elsif/else conditions of a nestable block.
public void setCausedByInvalidVar(java.lang.String varName)
Marks this exeption as being caused by an invalid variable or parameter name.
varName
- the variable or parameter name causing the problempublic java.io.File getFile()
Returns the parsed file.
public void setFile(java.io.File file)
Sets the parsed file.
file
- Parsed file.public void setStackTrace(java.util.Deque<StackTraceElement> stack)
Sets the given call stack.
stack
- the call stack to be set.public java.lang.String getFullMessage()
Returns the message including file name, line number, line content and/or stack trace, whatever is available.
public java.util.Deque<StackTraceElement> getStackTraceElements()
Returns a clone of the stack trace.
private void addLastElementIfNotYetDone()
Adds the final element to the stack trace, if not yet done.