jmbuilder.exception package#
Exception Module for JMBuilder
This module contains several custom exception for JMBuilder.
Copyright (c) 2023-2024 Ryuu Mitsuki.
Available Classes#
- JMException
This is base exception class for all custom exception classes in this module and this class extends to Exception class.
- JMUnknownTypeError
This class extends to JMException and raised when an unknown type error occurs during the execution of the package.
- exception jmbuilder.exception.JMException(*args, **kwargs)[source]#
Bases:
Exception
Base custom exception for JMBuilder. This class also provides traceback control (i.e., customizable).
- Parameters:
- *argslist of positional arguments
This parameter accepts a variable number of arguments. It treats the first argument as a format message and the subsequent arguments as format arguments. If only one argument is specified, it will be treated as a literal message. The formatting follows the conventions of C-style string formatting. For example:
# Assuming we have an index variable with a value of 5 >>> JMException('Invalid index: %d', index) JMException('Invalid index: 5', custom_traceback=False) # Using multiple format arguments >>> JMException('Invalid index: %d, at file: %s', 2, 'foo.py') JMException('Invalid index: 2, at file foo.py', custom_traceback=False)
- **kwargskeyword arguments
Arbitrary keyword arguments are accepted. Users can also unpack a dictionary into this parameter. All keyword arguments will be passed to the base exception class (i.e., the Exception class), except for the following reserved keywords:
tb
trace
traces
These reserved keywords allow users to control the exception’s traceback behavior. If more than one of these keywords is specified, the tb keyword will take precedence. However, be cautious when specifying multiple reserved keywords, as this can lead to unexpected behavior due to other arguments being passed to the base exception class.
- Raises:
- TypeError
If the given arguments (other than the first argument) are different with the format specifier at the first argument. For instance:
>>> JMBuilder('Syntax error at line: %d', '44') TypeError: %d format: a real number is required, not str
- property message: Optional[str]#
Get the detail message of this exception.
- Returns:
- str or None
The message of this exception. If not specified, returns
None
.
- property traces: StackSummary#
Get the stack traces of this exception.
- Returns:
- traceback.StackSummary
The stack traces of this exception. If not specified, returns the stack traces from
traceback.extract_stack()
.
- exception jmbuilder.exception.JMParserError(*args, **kwargs)[source]#
Bases:
JMException
Raised when an error has occurred during parsing the configuration.
- Parameters:
- *argslist of arguments
This parameter accepts a variable number of arguments.
- **kwargskeyword arguments
Additional keyword arguments to customize the exception.
Notes
For more details about arguments, see JMException documentation.
- property message: Optional[str]#
Get the detail message of this exception.
- Returns:
- str or None
The detail message of this exception. If not specified, returns
None
.
- property traces: StackSummary#
Get the stack traces of this exception.
- Returns:
- traceback.StackSummary
The stack traces of this exception. If not specified, returns the stack traces from traceback.extract_stack().
- exception jmbuilder.exception.JMUnknownTypeError(*args, **kwargs)[source]#
Bases:
JMException
,TypeError
Custom exception for unknown type errors.
This exception is raised when an unknown type error occurs during the execution of the software.
- Parameters:
- *argslist of arguments
This parameter accepts a variable number of arguments.
- **kwargskeyword arguments
Additional keyword arguments to customize the exception.
Notes
For more details about arguments, see JMException documentation.
- property message: Optional[str]#
Get the detail message of this exception.
- Returns:
- str or None
The message of this exception. If not specified, returns
None
.
- property traces: StackSummary#
Get the stack traces of this exception.
- Returns:
- traceback.StackSummary
The stack traces of this exception. If not specified, returns the stack traces from traceback.extract_stack().
Submodules#
jmbuilder.exception.exception module#
Custom Exceptions Module for JMBuilder
This module provides all custom exceptions for JMBuilder.
Copyright (c) 2023-2024 Ryuu Mitsuki.
Available Classes#
- JMException :
The base custom exception for JMBuilder.
- JMUnknownTypeError :
The custom exception that raised when an unknown type error occurs during the execution of the software.
- JMParserError :
Raised when an error has occurred during parsing the configuration.
- exception jmbuilder.exception.exception.JMException(*args, **kwargs)[source]#
Bases:
Exception
Base custom exception for JMBuilder. This class also provides traceback control (i.e., customizable).
- Parameters:
- *argslist of positional arguments
This parameter accepts a variable number of arguments. It treats the first argument as a format message and the subsequent arguments as format arguments. If only one argument is specified, it will be treated as a literal message. The formatting follows the conventions of C-style string formatting. For example:
# Assuming we have an index variable with a value of 5 >>> JMException('Invalid index: %d', index) JMException('Invalid index: 5', custom_traceback=False) # Using multiple format arguments >>> JMException('Invalid index: %d, at file: %s', 2, 'foo.py') JMException('Invalid index: 2, at file foo.py', custom_traceback=False)
- **kwargskeyword arguments
Arbitrary keyword arguments are accepted. Users can also unpack a dictionary into this parameter. All keyword arguments will be passed to the base exception class (i.e., the Exception class), except for the following reserved keywords:
tb
trace
traces
These reserved keywords allow users to control the exception’s traceback behavior. If more than one of these keywords is specified, the tb keyword will take precedence. However, be cautious when specifying multiple reserved keywords, as this can lead to unexpected behavior due to other arguments being passed to the base exception class.
- Raises:
- TypeError
If the given arguments (other than the first argument) are different with the format specifier at the first argument. For instance:
>>> JMBuilder('Syntax error at line: %d', '44') TypeError: %d format: a real number is required, not str
- property message: Optional[str]#
Get the detail message of this exception.
- Returns:
- str or None
The message of this exception. If not specified, returns
None
.
- property traces: StackSummary#
Get the stack traces of this exception.
- Returns:
- traceback.StackSummary
The stack traces of this exception. If not specified, returns the stack traces from
traceback.extract_stack()
.
- exception jmbuilder.exception.exception.JMParserError(*args, **kwargs)[source]#
Bases:
JMException
Raised when an error has occurred during parsing the configuration.
- Parameters:
- *argslist of arguments
This parameter accepts a variable number of arguments.
- **kwargskeyword arguments
Additional keyword arguments to customize the exception.
Notes
For more details about arguments, see JMException documentation.
- property message: Optional[str]#
Get the detail message of this exception.
- Returns:
- str or None
The detail message of this exception. If not specified, returns
None
.
- property traces: StackSummary#
Get the stack traces of this exception.
- Returns:
- traceback.StackSummary
The stack traces of this exception. If not specified, returns the stack traces from traceback.extract_stack().
- exception jmbuilder.exception.exception.JMUnknownTypeError(*args, **kwargs)[source]#
Bases:
JMException
,TypeError
Custom exception for unknown type errors.
This exception is raised when an unknown type error occurs during the execution of the software.
- Parameters:
- *argslist of arguments
This parameter accepts a variable number of arguments.
- **kwargskeyword arguments
Additional keyword arguments to customize the exception.
Notes
For more details about arguments, see JMException documentation.
- property message: Optional[str]#
Get the detail message of this exception.
- Returns:
- str or None
The message of this exception. If not specified, returns
None
.
- property traces: StackSummary#
Get the stack traces of this exception.
- Returns:
- traceback.StackSummary
The stack traces of this exception. If not specified, returns the stack traces from traceback.extract_stack().