tiferet 1.0.0a19__py3-none-any.whl → 1.0.0b0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tiferet/__init__.py +3 -2
- tiferet/commands/__init__.py +6 -0
- tiferet/commands/app.py +102 -0
- tiferet/commands/core.py +124 -0
- tiferet/commands/dependencies.py +76 -0
- tiferet/commands/settings.py +101 -0
- tiferet/configs/__init__.py +3 -67
- tiferet/configs/error.py +48 -0
- tiferet/configs/settings.py +37 -0
- tiferet/contexts/__init__.py +0 -8
- tiferet/contexts/app.py +215 -182
- tiferet/contexts/cache.py +76 -0
- tiferet/contexts/container.py +92 -190
- tiferet/contexts/error.py +78 -80
- tiferet/contexts/feature.py +120 -83
- tiferet/contracts/__init__.py +4 -0
- tiferet/contracts/app.py +92 -0
- tiferet/contracts/cache.py +70 -0
- tiferet/contracts/container.py +147 -0
- tiferet/contracts/error.py +177 -0
- tiferet/contracts/feature.py +159 -0
- tiferet/contracts/settings.py +34 -0
- tiferet/data/__init__.py +3 -4
- tiferet/data/app.py +71 -208
- tiferet/data/container.py +52 -38
- tiferet/data/error.py +15 -24
- tiferet/data/feature.py +27 -8
- tiferet/{domain/core.py → data/settings.py} +36 -96
- tiferet/handlers/__init__.py +0 -0
- tiferet/handlers/container.py +116 -0
- tiferet/handlers/error.py +49 -0
- tiferet/handlers/feature.py +94 -0
- tiferet/models/__init__.py +4 -0
- tiferet/models/app.py +150 -0
- tiferet/models/container.py +135 -0
- tiferet/{domain → models}/error.py +86 -36
- tiferet/{domain → models}/feature.py +107 -47
- tiferet/models/settings.py +148 -0
- tiferet/proxies/__init__.py +0 -0
- tiferet/proxies/yaml/__init__.py +0 -0
- tiferet/{repos → proxies/yaml}/app.py +13 -41
- tiferet/{repos → proxies/yaml}/container.py +26 -56
- tiferet/{repos → proxies/yaml}/error.py +11 -70
- tiferet/proxies/yaml/feature.py +92 -0
- {tiferet-1.0.0a19.dist-info → tiferet-1.0.0b0.dist-info}/METADATA +12 -3
- tiferet-1.0.0b0.dist-info/RECORD +51 -0
- {tiferet-1.0.0a19.dist-info → tiferet-1.0.0b0.dist-info}/WHEEL +1 -1
- tiferet/commands/container.py +0 -54
- tiferet/commands/error.py +0 -21
- tiferet/commands/feature.py +0 -90
- tiferet/contexts/request.py +0 -110
- tiferet/domain/__init__.py +0 -5
- tiferet/domain/app.py +0 -131
- tiferet/domain/container.py +0 -141
- tiferet/repos/__init__.py +0 -7
- tiferet/repos/feature.py +0 -151
- tiferet-1.0.0a19.dist-info/RECORD +0 -35
- {tiferet-1.0.0a19.dist-info → tiferet-1.0.0b0.dist-info/licenses}/LICENSE +0 -0
- {tiferet-1.0.0a19.dist-info → tiferet-1.0.0b0.dist-info}/top_level.txt +0 -0
tiferet/__init__.py
CHANGED
tiferet/commands/__init__.py
CHANGED
tiferet/commands/app.py
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
# *** imports
|
2
|
+
|
3
|
+
# ** app
|
4
|
+
from .settings import *
|
5
|
+
from .core import import_dependency
|
6
|
+
from ..contracts.app import AppRepository, AppInterface
|
7
|
+
|
8
|
+
|
9
|
+
# *** commands:
|
10
|
+
|
11
|
+
# ** command: import_app_repository
|
12
|
+
class ImportAppRepository(Command):
|
13
|
+
'''
|
14
|
+
A command to import an app repository.
|
15
|
+
'''
|
16
|
+
|
17
|
+
# * method: execute
|
18
|
+
def execute(self,
|
19
|
+
app_repo_module_path: str = 'tiferet.proxies.yaml.app',
|
20
|
+
app_repo_class_name: str = 'AppYamlProxy',
|
21
|
+
app_repo_params: Dict[str, Any] = dict(
|
22
|
+
app_config_file='app/configs/app.yml'
|
23
|
+
),
|
24
|
+
**kwargs
|
25
|
+
) -> AppRepository:
|
26
|
+
'''
|
27
|
+
Execute the command.
|
28
|
+
|
29
|
+
:param app_repo_module_path: The application repository module path.
|
30
|
+
:type app_repo_module_path: str
|
31
|
+
:param app_repo_class_name: The application repository class name.
|
32
|
+
:type app_repo_class_name: str
|
33
|
+
:param app_repo_params: The application repository parameters.
|
34
|
+
:type app_repo_params: dict
|
35
|
+
:param kwargs: Additional keyword arguments.
|
36
|
+
:type kwargs: dict
|
37
|
+
:return: The application repository instance.
|
38
|
+
:rtype: AppRepository
|
39
|
+
:raises TiferetError: If the import fails.
|
40
|
+
'''
|
41
|
+
|
42
|
+
# Import the app repository.
|
43
|
+
try:
|
44
|
+
result = import_dependency.execute(
|
45
|
+
app_repo_module_path,
|
46
|
+
app_repo_class_name
|
47
|
+
)(**app_repo_params)
|
48
|
+
|
49
|
+
# Raise an error if the import fails.
|
50
|
+
except TiferetError as e:
|
51
|
+
self.raise_error(
|
52
|
+
'APP_REPOSITORY_IMPORT_FAILED',
|
53
|
+
f'Failed to import app repository: {e}.',
|
54
|
+
str(e)
|
55
|
+
)
|
56
|
+
|
57
|
+
# Return the imported app repository.
|
58
|
+
return result
|
59
|
+
|
60
|
+
|
61
|
+
# ** command: get_app_interface
|
62
|
+
class GetAppInterface(Command):
|
63
|
+
'''
|
64
|
+
A command to get the application interface by its ID.
|
65
|
+
'''
|
66
|
+
|
67
|
+
def __init__(self, app_repo: AppRepository):
|
68
|
+
'''
|
69
|
+
Initialize the LoadAppInterface command.
|
70
|
+
|
71
|
+
:param app_repo: The application repository instance.
|
72
|
+
:type app_repo: AppRepository
|
73
|
+
'''
|
74
|
+
|
75
|
+
# Set the application repository.
|
76
|
+
self.app_repo = app_repo
|
77
|
+
|
78
|
+
# * method: execute
|
79
|
+
def execute(self, interface_id: str, **kwargs) -> AppInterface:
|
80
|
+
'''
|
81
|
+
Execute the command to load the application interface.
|
82
|
+
|
83
|
+
:param interface_id: The ID of the application interface to load.
|
84
|
+
:type interface_id: str
|
85
|
+
:param kwargs: Additional keyword arguments.
|
86
|
+
:type kwargs: dict
|
87
|
+
:return: The loaded application interface.
|
88
|
+
:rtype: AppInterface
|
89
|
+
:raises TiferetError: If the interface cannot be found.
|
90
|
+
'''
|
91
|
+
|
92
|
+
# Load the application interface.
|
93
|
+
# Raise an error if the interface is not found.
|
94
|
+
interface = self.app_repo.get_interface(interface_id)
|
95
|
+
if not interface:
|
96
|
+
self.raise_error(
|
97
|
+
'APP_INTERFACE_NOT_FOUND',
|
98
|
+
f'App interface with ID {interface_id} not found.'
|
99
|
+
)
|
100
|
+
|
101
|
+
# Return the loaded application interface.
|
102
|
+
return interface
|
tiferet/commands/core.py
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
# *** imports
|
2
|
+
|
3
|
+
# ** core
|
4
|
+
from typing import Dict, Any
|
5
|
+
import os
|
6
|
+
from importlib import import_module
|
7
|
+
|
8
|
+
# ** app
|
9
|
+
from .settings import *
|
10
|
+
|
11
|
+
|
12
|
+
# *** commands
|
13
|
+
|
14
|
+
# ** command: parse_parameter
|
15
|
+
class ParseParameter(Command):
|
16
|
+
'''
|
17
|
+
A command to parse a parameter from a string.
|
18
|
+
'''
|
19
|
+
|
20
|
+
# * method: execute
|
21
|
+
def execute(self, parameter: str) -> Dict[str, Any]:
|
22
|
+
'''
|
23
|
+
Execute the command.
|
24
|
+
|
25
|
+
:param parameter: The parameter to parse.
|
26
|
+
:type parameter: str
|
27
|
+
:return: The parsed parameter.
|
28
|
+
:rtype: str
|
29
|
+
'''
|
30
|
+
|
31
|
+
# Parse the parameter.
|
32
|
+
try:
|
33
|
+
|
34
|
+
# If the parameter is an environment variable, get the value.
|
35
|
+
if parameter.startswith('$env.'):
|
36
|
+
result = os.getenv(parameter[5:])
|
37
|
+
|
38
|
+
# Raise an exception if the environment variable is not found.
|
39
|
+
if not result:
|
40
|
+
raise Exception('Environment variable not found.')
|
41
|
+
|
42
|
+
# Return the result if the environment variable is found.
|
43
|
+
return result
|
44
|
+
|
45
|
+
# Return the parameter as is if it is not an environment variable.
|
46
|
+
return parameter
|
47
|
+
|
48
|
+
# Raise an error if the parameter parsing fails.
|
49
|
+
except Exception as e:
|
50
|
+
self.raise_error(
|
51
|
+
'PARAMETER_PARSING_FAILED',
|
52
|
+
f'Failed to parse parameter: {parameter}. Error: {str(e)}',
|
53
|
+
parameter,
|
54
|
+
str(e)
|
55
|
+
)
|
56
|
+
|
57
|
+
|
58
|
+
# ** command: import_dependency
|
59
|
+
class ImportDependency(Command):
|
60
|
+
'''
|
61
|
+
A command to import a dependency from a module.
|
62
|
+
'''
|
63
|
+
|
64
|
+
# * method: execute
|
65
|
+
def execute(self, module_path: str, class_name: str, **kwargs) -> Any:
|
66
|
+
'''
|
67
|
+
Execute the command.
|
68
|
+
|
69
|
+
:param module_path: The module path to import from.
|
70
|
+
:type module_path: str
|
71
|
+
:param class_name: The class name to import.
|
72
|
+
:type class_name: str
|
73
|
+
:param kwargs: Additional keyword arguments.
|
74
|
+
:type kwargs: dict
|
75
|
+
:return: The imported class instance.
|
76
|
+
:rtype: Any
|
77
|
+
'''
|
78
|
+
|
79
|
+
# Import module.
|
80
|
+
try:
|
81
|
+
return getattr(import_module(module_path), class_name)
|
82
|
+
|
83
|
+
# Raise an error if the dependency import fails.
|
84
|
+
except Exception as e:
|
85
|
+
self.raise_error(
|
86
|
+
'IMPORT_DEPENDENCY_FAILED',
|
87
|
+
f'Failed to import dependency: {module_path} from module {class_name}. Error: {str(e)}',
|
88
|
+
module_path,
|
89
|
+
class_name,
|
90
|
+
str(e),
|
91
|
+
)
|
92
|
+
|
93
|
+
|
94
|
+
# ** command: raise_error
|
95
|
+
class RaiseError(Command):
|
96
|
+
'''
|
97
|
+
A command to raise an error with a specific message.
|
98
|
+
'''
|
99
|
+
|
100
|
+
# * method: execute
|
101
|
+
def execute(self, error_code: str, message: str = None, *args) -> None:
|
102
|
+
'''
|
103
|
+
Execute the command.
|
104
|
+
|
105
|
+
:param error_code: The error code to raise.
|
106
|
+
:type error_code: str
|
107
|
+
:param args: Additional arguments for the error message.
|
108
|
+
:type args: tuple
|
109
|
+
'''
|
110
|
+
|
111
|
+
# Raise an error with the specified code and arguments.
|
112
|
+
raise TiferetError(error_code, message, *args)
|
113
|
+
|
114
|
+
|
115
|
+
# *** command_variables
|
116
|
+
|
117
|
+
# ** command_variable: parse_parameter
|
118
|
+
parse_parameter = ParseParameter()
|
119
|
+
|
120
|
+
# ** command_variable: import_dependency
|
121
|
+
import_dependency = ImportDependency()
|
122
|
+
|
123
|
+
# ** command_variable: raise_error
|
124
|
+
raise_error = RaiseError()
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# *** imports
|
2
|
+
|
3
|
+
# ** core
|
4
|
+
from typing import Any, Dict
|
5
|
+
|
6
|
+
# ** infra
|
7
|
+
from dependencies import Injector
|
8
|
+
from dependencies.exceptions import DependencyError
|
9
|
+
|
10
|
+
# ** app
|
11
|
+
from ..commands import *
|
12
|
+
|
13
|
+
|
14
|
+
# *** commands
|
15
|
+
|
16
|
+
# ** command: create_injector
|
17
|
+
class CreateInjector(Command):
|
18
|
+
'''
|
19
|
+
A command to create a dependencies (library) injector object with the given dependencies.
|
20
|
+
'''
|
21
|
+
|
22
|
+
def execute(self, name: str, dependencies: Dict[str, type], **kwargs) -> Any:
|
23
|
+
'''
|
24
|
+
Execute the command to create an injector object.
|
25
|
+
|
26
|
+
:param name: The name of the injector.
|
27
|
+
:type name: str
|
28
|
+
:param dependencies: The dependencies.
|
29
|
+
:type dependencies: dict
|
30
|
+
:return: The injector object.
|
31
|
+
:rtype: Any
|
32
|
+
'''
|
33
|
+
|
34
|
+
# Create container.
|
35
|
+
return type(name, (Injector,), {**dependencies, **kwargs})
|
36
|
+
|
37
|
+
|
38
|
+
# ** command: get_dependency
|
39
|
+
class GetDependency(Command):
|
40
|
+
'''
|
41
|
+
A command to get a dependency from the injector.
|
42
|
+
'''
|
43
|
+
|
44
|
+
def execute(self, injector: Injector, dependency_name: str) -> Any:
|
45
|
+
'''
|
46
|
+
Execute the command to get a dependency from the injector.
|
47
|
+
|
48
|
+
:param injector: The injector object.
|
49
|
+
:type injector: Injector
|
50
|
+
:param dependency_name: The name of the dependency to get.
|
51
|
+
:type dependency_name: str
|
52
|
+
:return: The dependency object.
|
53
|
+
:rtype: Any
|
54
|
+
'''
|
55
|
+
|
56
|
+
# Return the dependency from the injector.
|
57
|
+
try:
|
58
|
+
return getattr(injector, dependency_name)
|
59
|
+
|
60
|
+
# If the dependency does not exist or cannot be resolved, raise an error.
|
61
|
+
except DependencyError as e:
|
62
|
+
self.raise_error(
|
63
|
+
'INVALID_DEPENDENCY_ERROR',
|
64
|
+
f'Dependency {dependency_name} could not be resolved: {str(e)}',
|
65
|
+
dependency_name,
|
66
|
+
str(e)
|
67
|
+
)
|
68
|
+
|
69
|
+
|
70
|
+
# *** command_variables
|
71
|
+
|
72
|
+
# ** command_variable: create_injector
|
73
|
+
create_injector = CreateInjector()
|
74
|
+
|
75
|
+
# ** command_variable: get_dependency
|
76
|
+
get_dependency = GetDependency()
|
@@ -0,0 +1,101 @@
|
|
1
|
+
# *** imports
|
2
|
+
|
3
|
+
# ** core
|
4
|
+
from typing import Dict, Any
|
5
|
+
|
6
|
+
# ** app
|
7
|
+
from ..configs import TiferetError
|
8
|
+
|
9
|
+
|
10
|
+
# *** classes
|
11
|
+
|
12
|
+
# ** class: command
|
13
|
+
class Command(object):
|
14
|
+
'''
|
15
|
+
A base class for an app command object.
|
16
|
+
'''
|
17
|
+
|
18
|
+
# * method: execute
|
19
|
+
def execute(self, **kwargs) -> Any:
|
20
|
+
'''
|
21
|
+
Execute the service command.
|
22
|
+
|
23
|
+
:param kwargs: The command arguments.
|
24
|
+
:type kwargs: dict
|
25
|
+
:return: The command result.
|
26
|
+
:rtype: Any
|
27
|
+
'''
|
28
|
+
|
29
|
+
# Not implemented.
|
30
|
+
raise NotImplementedError()
|
31
|
+
|
32
|
+
# * method: raise_error
|
33
|
+
def raise_error(self, error_code: str, message: str = None, *args):
|
34
|
+
'''
|
35
|
+
Raise an error with the given error code and arguments.
|
36
|
+
|
37
|
+
:param error_code: The error code.
|
38
|
+
:type error_code: str
|
39
|
+
:param message: The error message.
|
40
|
+
:type message: str
|
41
|
+
:param args: Additional error arguments.
|
42
|
+
:type args: tuple
|
43
|
+
'''
|
44
|
+
|
45
|
+
# Raise the TiferetError with the given error code and arguments.
|
46
|
+
raise TiferetError(
|
47
|
+
error_code,
|
48
|
+
message,
|
49
|
+
*args
|
50
|
+
)
|
51
|
+
|
52
|
+
# * method: verify
|
53
|
+
def verify(self, expression: bool, error_code: str, message: str = None, *args):
|
54
|
+
'''
|
55
|
+
Verify an expression and raise an error if it is false.
|
56
|
+
|
57
|
+
:param expression: The expression to verify.
|
58
|
+
:type expression: bool
|
59
|
+
:param error_code: The error code.
|
60
|
+
:type error_code: str
|
61
|
+
:param message: The error message.
|
62
|
+
:type message: str
|
63
|
+
:param args: Additional error arguments.
|
64
|
+
:type args: tuple
|
65
|
+
'''
|
66
|
+
|
67
|
+
# Verify the expression.
|
68
|
+
try:
|
69
|
+
assert expression
|
70
|
+
except AssertionError:
|
71
|
+
self.raise_error(
|
72
|
+
error_code,
|
73
|
+
message,
|
74
|
+
*args
|
75
|
+
)
|
76
|
+
|
77
|
+
# * method: handle
|
78
|
+
@staticmethod
|
79
|
+
def handle(
|
80
|
+
command: type,
|
81
|
+
dependencies: Dict[str, Any] = {},
|
82
|
+
**kwargs) -> Any:
|
83
|
+
'''
|
84
|
+
Handle an app command instance.
|
85
|
+
|
86
|
+
:param command: The command to handle.
|
87
|
+
:type command: type
|
88
|
+
:param dependencies: The command dependencies.
|
89
|
+
:type dependencies: Dict[str, Any]
|
90
|
+
:param kwargs: Additional keyword arguments.
|
91
|
+
:type kwargs: dict
|
92
|
+
:return: The result of the command.
|
93
|
+
:rtype: Any
|
94
|
+
'''
|
95
|
+
|
96
|
+
# Get the command handler.
|
97
|
+
command_handler = command(**dependencies)
|
98
|
+
|
99
|
+
# Execute the command handler.
|
100
|
+
result = command_handler.execute(**kwargs)
|
101
|
+
return result
|
tiferet/configs/__init__.py
CHANGED
@@ -1,69 +1,5 @@
|
|
1
1
|
# *** imports
|
2
2
|
|
3
|
-
# **
|
4
|
-
from
|
5
|
-
|
6
|
-
|
7
|
-
# *** config
|
8
|
-
|
9
|
-
# ** config (class): string_type
|
10
|
-
class StringType(t.StringType):
|
11
|
-
'''
|
12
|
-
A string type.
|
13
|
-
'''
|
14
|
-
|
15
|
-
pass
|
16
|
-
|
17
|
-
|
18
|
-
# ** config (class): integer_type
|
19
|
-
class IntegerType(t.IntType):
|
20
|
-
'''
|
21
|
-
An integer type.
|
22
|
-
'''
|
23
|
-
|
24
|
-
pass
|
25
|
-
|
26
|
-
|
27
|
-
# ** config (class): float_type
|
28
|
-
class FloatType(t.FloatType):
|
29
|
-
'''
|
30
|
-
A float type.
|
31
|
-
'''
|
32
|
-
|
33
|
-
pass
|
34
|
-
|
35
|
-
|
36
|
-
# ** config (class): boolean_type
|
37
|
-
class BooleanType(t.BooleanType):
|
38
|
-
'''
|
39
|
-
A boolean type.
|
40
|
-
'''
|
41
|
-
|
42
|
-
pass
|
43
|
-
|
44
|
-
|
45
|
-
# ** config (class): list_type
|
46
|
-
class ListType(t.ListType):
|
47
|
-
'''
|
48
|
-
A list type.
|
49
|
-
'''
|
50
|
-
|
51
|
-
pass
|
52
|
-
|
53
|
-
|
54
|
-
# ** config (class): dict_type
|
55
|
-
class DictType(t.DictType):
|
56
|
-
'''
|
57
|
-
A dictionary type.
|
58
|
-
'''
|
59
|
-
|
60
|
-
pass
|
61
|
-
|
62
|
-
|
63
|
-
# ** config (class): model_type
|
64
|
-
class ModelType(t.ModelType):
|
65
|
-
'''
|
66
|
-
A model type.
|
67
|
-
'''
|
68
|
-
|
69
|
-
pass
|
3
|
+
# ** app
|
4
|
+
from .settings import *
|
5
|
+
from ..models.settings import *
|
tiferet/configs/error.py
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# *** imports
|
2
|
+
|
3
|
+
|
4
|
+
# *** configs
|
5
|
+
|
6
|
+
# ** config: errors
|
7
|
+
ERRORS = [
|
8
|
+
dict(
|
9
|
+
id='parameter_parsing_failed',
|
10
|
+
name='Parameter Parsing Failed',
|
11
|
+
error_code='PARAMETER_PARSING_FAILED',
|
12
|
+
message=[
|
13
|
+
dict(lang='en_US', text='Failed to parse parameter: {}. Error: {}')
|
14
|
+
]
|
15
|
+
),
|
16
|
+
dict(
|
17
|
+
id='import_dependency_failed',
|
18
|
+
name='Import Dependency Failed',
|
19
|
+
error_code='IMPORT_DEPENDENCY_FAILED',
|
20
|
+
message=[
|
21
|
+
dict(lang='en_US', text='Failed to import dependency: {} from module {}. Error: {}')
|
22
|
+
]
|
23
|
+
),
|
24
|
+
dict(
|
25
|
+
id='app_repository_import_failed',
|
26
|
+
name='App Repository Import Failed',
|
27
|
+
error_code='APP_REPOSITORY_IMPORT_FAILED',
|
28
|
+
message=[
|
29
|
+
dict(lang='en_US', text='Failed to import app repository: {}.')
|
30
|
+
]
|
31
|
+
),
|
32
|
+
dict(
|
33
|
+
id='app_interface_not_found',
|
34
|
+
name='App Interface Not Found',
|
35
|
+
error_code='APP_INTERFACE_NOT_FOUND',
|
36
|
+
message=[
|
37
|
+
dict(lang='en_US', text='App interface with ID {} not found.')
|
38
|
+
]
|
39
|
+
),
|
40
|
+
dict(
|
41
|
+
id='feature_command_loading_failed',
|
42
|
+
name='Feature Command Loading Failed',
|
43
|
+
error_code='FEATURE_COMMAND_LOADING_FAILED',
|
44
|
+
message=[
|
45
|
+
dict(lang='en_US', text='Failed to load feature command attribute: {}. Ensure the container attributes are configured with the appropriate default settings/flags. {}')
|
46
|
+
]
|
47
|
+
)
|
48
|
+
]
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# *** imports
|
2
|
+
|
3
|
+
# ** core
|
4
|
+
import json
|
5
|
+
|
6
|
+
|
7
|
+
# *** classes
|
8
|
+
|
9
|
+
|
10
|
+
# ** class: tiferet_error
|
11
|
+
class TiferetError(Exception):
|
12
|
+
'''
|
13
|
+
A base exception for Tiferet.
|
14
|
+
'''
|
15
|
+
|
16
|
+
def __init__(self, error_code: str, message: str = None, *args):
|
17
|
+
'''
|
18
|
+
Initialize the exception.
|
19
|
+
|
20
|
+
:param error_code: The error code.
|
21
|
+
:type error_code: str
|
22
|
+
:param message: An optional error message for internal exception handling.
|
23
|
+
:type message: str
|
24
|
+
:param args: Additional arguments for the error message.
|
25
|
+
:type args: tuple
|
26
|
+
'''
|
27
|
+
|
28
|
+
# Set the error code and arguments.
|
29
|
+
self.error_code = error_code
|
30
|
+
|
31
|
+
# Initialize base exception with error data.
|
32
|
+
super().__init__(
|
33
|
+
json.dumps(dict(
|
34
|
+
error_code=error_code,
|
35
|
+
message=message,
|
36
|
+
)), *args
|
37
|
+
)
|
tiferet/contexts/__init__.py
CHANGED