Skip to content

Commit e2447f6

Browse files
committed
refactor[BREAKING]: resulterr remove error codes and groups
The ResultErr class defined an attribute `code` that stored an int error codes and maintained a dictionary of error codes to error definitions. This feature made the rest of the ResultContainer overly complex for minimal added benefit, so it was removed. This also removed the class based error group dictionaries. A backup of the original python, with error codes, will be archived on the error_codes branch.
1 parent 421b911 commit e2447f6

File tree

3 files changed

+188
-553
lines changed

3 files changed

+188
-553
lines changed

README.md

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,17 @@ from ResultContainer import Result, Ok, Err
101101
from ResultContainer import Result, Ok, Err
102102

103103
# Main object signature:
104-
res = Result(value, success, error_msg, error_code, error_code_group, add_traceback, deepcopy) # Construct either Ok or Er
104+
res = Result(value, success, error_msg, add_traceback, deepcopy) # Construct either Ok or Er
105105

106106
# Classmethod signatures:
107-
res = Result.as_Ok(value, deepcopy, error_code_group) # Construct Ok variant
107+
res = Result.as_Ok(value, deepcopy) # Construct Ok variant
108108

109-
res = Result.as_Err(error_msg, error_code, error_code_group, add_traceback) # Construct Err variant
109+
res = Result.as_Err(error_msg, add_traceback) # Construct Err variant
110110

111111
# Syntact Sugar Constructors:
112-
res = Ok(value, deepcopy, error_code_group) # Construct Ok variant
112+
res = Ok(value, deepcopy) # Construct Ok variant
113113

114-
res = Err(error_msg, error_code, error_code_group, add_traceback) # Construct Err variant
114+
res = Err(error_msg, add_traceback) # Construct Err variant
115115

116116
# Arguments:
117117
# value (Any): The value to wrap in the Ok(value).
@@ -123,14 +123,6 @@ res = Err(error_msg, error_code, error_code_group, add_traceback) # Co
123123
# b) otherwise, return Err( str(error_msg) ),
124124
# if error_msg is listlike, then each item is appended as a separate message.
125125
# Default is "".
126-
# error_code (int, optional): Error code associated with the error.
127-
# Default is `1` for `Unspecified`.
128-
# A dict of the currently assigned error codes are returned with Result.error_code()
129-
# Note, the code description does not have to match the error_msg.
130-
# error_code_group (int, optional): Specify the error_codes group to use for code and message flags.
131-
# Default is 1. Error codes are stored as a class variable,
132-
# so this is useful if you need different sets of error codes within a program.
133-
# Most of the time you will never need to use this feature!
134126
# add_traceback (bool, optional): If True and constructing Err variant, adds traceback information to Err.
135127
# Default is True.
136128
# deepcopy (bool, optional): If True, then deepcopy value before wrapping in Ok. Default is False.
@@ -167,7 +159,7 @@ Err_traceback (list[list[str]]):
167159
### Methods
168160

169161
```
170-
raises(add_traceback=False, error_msg="", error_code=1):
162+
raises(add_traceback=False, error_msg=""):
171163
If Ok variant, then returns Ok(value);
172164
If Err variant, then raises a ResultErr exception.
173165
@@ -233,7 +225,7 @@ iter_wrap(expand=False):
233225
Always iterates at least once for Ok, and does not iterate for Err.
234226
If expand is True, then returns list(iter_unwrap()).
235227
236-
add_Err_msg(error_msg, error_code=1, add_traceback=True)):
228+
add_Err_msg(error_msg, add_traceback=True)):
237229
For the Ok(value) variant, converts to Err(error_msg).
238230
For the Err(e) variant, adds an error message.
239231

0 commit comments

Comments
 (0)