pyccel.errors.errors module#
This module contains classes and methods that manipilate the various errors and warnings that could be shown by pyccel.
- class pyccel.errors.errors.ErrorInfo(*, stage, filename, message, line=None, column=None, severity=None, symbol=None, traceback=None)[source]#
Bases:
object
Representation of a single error message.
A class which holds all of the information necessary to describe an error message raised by Pyccel.
- Parameters:
stage (str) – The Pyccel stage when the error occurred.
filename (str) – The file where the error was detected.
message (str) – The message to be displayed to the user.
line (int, optional) – The line where the error was detected.
column (int, optional) – The column in the line of code where the error was detected.
severity (str, optional) – The severity of the error. This is one of : [warning/error/fatal].
symbol (str, optional) – A string representation of the PyccelAstNode object which caused the error to need to be raised. This object is printed in the error message.
traceback (str, optional) – The traceback describing the execution of the code when the error was raised.
- class pyccel.errors.errors.Errors(self)[source]#
Bases:
object
Container for compile errors.
A singleton class which contains all functions necessary to raise neat user-friendly errors in Pyccel.
- format_messages(error_info)[source]#
Return a string list that represents the error messages. Use a form suitable for displaying to the user.
- initialize()[source]#
Initialise the Errors singleton.
Initialise the Errors singleton. This function is necessary so the singleton can be reinitialised using the reset function.
- property mode#
- report(message, line=None, column=None, bounding_box=None, severity='error', symbol=None, filename=None, traceback=None)[source]#
Report an error.
Report message at the given line using the current error context stage: ‘syntactic’, ‘semantic’ ‘codegen’, or ‘cwrapper’.
- Parameters:
message (str) – The message to be displayed to the user.
line (int, optional) – The line at which the error can be found. Default: If a symbol is provided with a known line number then this line number is used.
column (int, optional) – The column at which the error can be found. Default: If a symbol is provided with a known column then this column is used.
bounding_box (tuple, optional) – An optional tuple containing the line and column.
severity (str, default='error') – Indicates the seriousness of the error. Should be one of: ‘warning’, ‘error’, ‘fatal’. Default: ‘error’.
symbol (pyccel.ast.PyccelAstNode, optional) – The PyccelAstNode object which caused the error to need to be raised. This object is printed in the error message.
filename (str, optional) – The file which was being treated when the error was found.
traceback (types.TracebackType) – The traceback that was raised when the error appeared.
- reset()[source]#
Reset the Errors singleton.
Reset the Errors singleton. This removes any information about previously generated errors or warnings. This method should be called before starting a new translation.
- set_target(target)[source]#
Set the current translation target.
Set the current translation target which describes the location from which the error is being raised.
- Parameters:
target (str) – The name of the file being translated.
- property target#
- class pyccel.errors.errors.ErrorsMode(self)[source]#
Bases:
object
The mode for the error output.
The mode for the error output. This is either ‘developer’ or ‘user’. In developer mode the errors are more verbose and include a traceback this helps developers debug errors.
- set_mode(mode)[source]#
Set the error mode.
Set the error mode to either ‘developer’ or ‘user’.
- Parameters:
mode (str) – The new error mode.
- property value#
- exception pyccel.errors.errors.PyccelCodegenError(message, errors='')[source]#
Bases:
PyccelError
- exception pyccel.errors.errors.PyccelSemanticError(message, errors='')[source]#
Bases:
PyccelError
- exception pyccel.errors.errors.PyccelSyntaxError(message, errors='')[source]#
Bases:
PyccelError