Skip to content

Commit 0ae8000

Browse files
[STYLE] Fixed line length as per conventions.
Changes in file multicast/exceptions.py: - minor style fix.
1 parent d517197 commit 0ae8000

File tree

1 file changed

+30
-5
lines changed

1 file changed

+30
-5
lines changed

multicast/exceptions.py

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ class CommandExecutionError(RuntimeError):
160160
message (str) -- Description of the error.
161161
exit_code (int) -- The exit code associated with the error.
162162
163+
Raises:
164+
TypeError: If exit_code is not an integer.
165+
163166
Meta-Testing:
164167
165168
Testcase 1: Initialization with message and exit code.
@@ -201,6 +204,18 @@ def __init__(self, *args, **kwargs):
201204
'Error message'
202205
>>> error.exit_code
203206
2
207+
208+
Testcase 2: Initialization with different call to init:
209+
A. - Initializes a CommandExecutionError with a specific exit code.
210+
B. - Checks the message is still set, as super class would.
211+
C. - check the specific exit code is 64.
212+
213+
>>> pre_made_args = ["A Pre-made Error Message", int(64)]
214+
>>> error = CommandExecutionError(*pre_made_args)
215+
>>> error.message
216+
'A Pre-made Error Message'
217+
>>> error.exit_code
218+
64
204219
"""
205220
if len(args) > 0 and isinstance(args[-1], int):
206221
exit_code = args[-1]
@@ -238,7 +253,8 @@ def __init__(self, *args, **kwargs):
238253
239254
The `EXIT_CODES` dictionary serves as a centralized mapping for standard exit codes used within
240255
the multicast module. Each key represents an exit code (as an integer), and each value is a tuple
241-
containing the associated exception class (or `None` if not applicable) and a human-readable description of the exit condition.
256+
containing the associated exception class (or `None` if not applicable) and a human-readable
257+
description of the exit condition.
242258
243259
CEP-8 Compliance:
244260
In accordance with [CEP-8]
@@ -321,7 +337,7 @@ def get_exit_code_from_exception(exc):
321337
"""
322338
Retrieve the exit code associated with a specific exception.
323339
324-
Parameters:
340+
Arguments:
325341
exc (BaseException): The exception instance from which to retrieve the exit code.
326342
327343
Returns:
@@ -330,14 +346,16 @@ def get_exit_code_from_exception(exc):
330346
Raises:
331347
TypeError: If the provided argument is not an instance of BaseException.
332348
333-
Meta-Testing:
349+
Testing:
334350
335351
Testcase 1: Exception with a mapped exit code.
352+
336353
>>> exc = FileNotFoundError('No such file or directory')
337354
>>> get_exit_code_from_exception(exc)
338355
66
339356
340357
Testcase 2: Exception without a specific exit code.
358+
341359
>>> exc = Exception('Generic error')
342360
>>> get_exit_code_from_exception(exc)
343361
70
@@ -360,13 +378,13 @@ def exit_on_exception(func):
360378
exceptions (which may be raised by modules like `argparse`) and other base exceptions result
361379
in the program exiting with meaningful exit codes and error messages.
362380
363-
Parameters:
381+
Arguments:
364382
func (callable): The function to be wrapped by the decorator.
365383
366384
Returns:
367385
callable: The wrapped function with enhanced exception handling.
368386
369-
Meta-Testing:
387+
Testing:
370388
371389
Testcase 1: Successful execution without exceptions.
372390
A. Define a function that returns a value.
@@ -426,3 +444,10 @@ def wrapper(*args, **kwargs):
426444
raise SystemExit(exit_code) from exc
427445
# otherwise sys.exit(exit_code)
428446
return wrapper
447+
448+
449+
__all__ = [
450+
"""__package__""", """__module__""", """__name__""", "__doc__",
451+
"CommandExecutionError", "EXCEPTION_EXIT_CODES", "EXIT_CODES",
452+
"get_exit_code_from_exception", "exit_on_exception"
453+
]

0 commit comments

Comments
 (0)