orionis 0.491.0__py3-none-any.whl → 0.493.0__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.
- orionis/console/base/scheduler.py +2 -8
- orionis/console/commands/scheduler_work.py +10 -0
- orionis/console/kernel.py +1 -2
- orionis/failure/base/__init__.py +0 -0
- orionis/failure/base/handler.py +103 -0
- orionis/failure/catch.py +32 -102
- orionis/failure/contracts/catch.py +15 -74
- orionis/failure/contracts/handler.py +38 -0
- orionis/foundation/application.py +88 -3
- orionis/foundation/contracts/application.py +63 -0
- orionis/metadata/framework.py +1 -1
- {orionis-0.491.0.dist-info → orionis-0.493.0.dist-info}/METADATA +1 -1
- {orionis-0.491.0.dist-info → orionis-0.493.0.dist-info}/RECORD +17 -14
- {orionis-0.491.0.dist-info → orionis-0.493.0.dist-info}/WHEEL +0 -0
- {orionis-0.491.0.dist-info → orionis-0.493.0.dist-info}/licenses/LICENCE +0 -0
- {orionis-0.491.0.dist-info → orionis-0.493.0.dist-info}/top_level.txt +0 -0
- {orionis-0.491.0.dist-info → orionis-0.493.0.dist-info}/zip-safe +0 -0
|
@@ -27,15 +27,9 @@ class BaseScheduler(IBaseScheduler):
|
|
|
27
27
|
None
|
|
28
28
|
This method does not return any value. It is intended to be overridden
|
|
29
29
|
by subclasses to specify scheduled tasks.
|
|
30
|
-
|
|
31
|
-
Notes
|
|
32
|
-
-----
|
|
33
|
-
Subclasses should implement this method to add specific tasks to the scheduler
|
|
34
|
-
using the provided `schedule` object. This method enforces that each subclass
|
|
35
|
-
defines its own scheduled tasks.
|
|
36
30
|
"""
|
|
37
|
-
#
|
|
38
|
-
|
|
31
|
+
# Placeholder for task registration logic
|
|
32
|
+
pass
|
|
39
33
|
|
|
40
34
|
def onStarted(self):
|
|
41
35
|
"""
|
|
@@ -82,6 +82,16 @@ class ScheduleWorkCommand(BaseCommand):
|
|
|
82
82
|
# Register scheduled tasks using the Scheduler's tasks method
|
|
83
83
|
Scheduler.tasks(schedule_serice)
|
|
84
84
|
|
|
85
|
+
# Retrieve the list of scheduled jobs/events
|
|
86
|
+
list_tasks = schedule_serice.events()
|
|
87
|
+
|
|
88
|
+
# Display a message if no scheduled jobs are found
|
|
89
|
+
if not list_tasks:
|
|
90
|
+
console.line()
|
|
91
|
+
console.print(Panel("No scheduled jobs found.", border_style="green"))
|
|
92
|
+
console.line()
|
|
93
|
+
return True
|
|
94
|
+
|
|
85
95
|
# Display a start message for the scheduler worker
|
|
86
96
|
console.line()
|
|
87
97
|
start_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
orionis/console/kernel.py
CHANGED
|
@@ -103,8 +103,7 @@ class KernelCLI(IKernelCLI):
|
|
|
103
103
|
except BaseException as e:
|
|
104
104
|
|
|
105
105
|
# Catch any exceptions that occur during command handling
|
|
106
|
-
self.__catch.
|
|
107
|
-
self.__catch.renderCLI(args, e)
|
|
106
|
+
self.__catch.exception(self, args, e)
|
|
108
107
|
|
|
109
108
|
# Exit the process with a non-zero status code to indicate an error
|
|
110
109
|
sys.exit(1)
|
|
File without changes
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
from typing import Any, List
|
|
2
|
+
from orionis.console.output.contracts.console import IConsole
|
|
3
|
+
from orionis.failure.contracts.handler import IBaseExceptionHandler
|
|
4
|
+
from orionis.failure.entities.throwable import Throwable
|
|
5
|
+
from orionis.services.log.contracts.log_service import ILogger
|
|
6
|
+
|
|
7
|
+
class BaseExceptionHandler(IBaseExceptionHandler):
|
|
8
|
+
|
|
9
|
+
# Exceptions that should not be caught by the handler
|
|
10
|
+
dont_cathc: List[type[BaseException]] = [
|
|
11
|
+
# Add specific exceptions that should not be caught
|
|
12
|
+
# Example: OrionisContainerException
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
def destructureException(self, e: BaseException) -> Throwable:
|
|
16
|
+
"""
|
|
17
|
+
Converts an exception into a structured `Throwable` object containing detailed information.
|
|
18
|
+
|
|
19
|
+
Parameters
|
|
20
|
+
----------
|
|
21
|
+
e : BaseException
|
|
22
|
+
The exception instance to be destructured.
|
|
23
|
+
|
|
24
|
+
Returns
|
|
25
|
+
-------
|
|
26
|
+
Throwable
|
|
27
|
+
A `Throwable` object encapsulating the exception's class type, message, arguments, and traceback.
|
|
28
|
+
|
|
29
|
+
Notes
|
|
30
|
+
-----
|
|
31
|
+
This method extracts the type, message, arguments, and traceback from the provided exception
|
|
32
|
+
and wraps them in a `Throwable` object for consistent error handling and reporting.
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
# Create and return a Throwable object with detailed exception information
|
|
36
|
+
return Throwable(
|
|
37
|
+
classtype=type(e), # The class/type of the exception
|
|
38
|
+
message=str(e), # The exception message as a string
|
|
39
|
+
args=e.args, # The arguments passed to the exception
|
|
40
|
+
traceback=getattr(e, '__traceback__', None) # The traceback object, if available
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
def report (self, exception: BaseException, log: ILogger) -> Any:
|
|
44
|
+
"""
|
|
45
|
+
Report or log an exception.
|
|
46
|
+
|
|
47
|
+
Parameters
|
|
48
|
+
----------
|
|
49
|
+
exception : BaseException
|
|
50
|
+
The exception instance that was caught.
|
|
51
|
+
|
|
52
|
+
Returns
|
|
53
|
+
-------
|
|
54
|
+
None
|
|
55
|
+
"""
|
|
56
|
+
# Ensure the provided object is an exception
|
|
57
|
+
if not isinstance(exception, BaseException):
|
|
58
|
+
raise TypeError(f"Expected BaseException, got {type(exception).__name__}")
|
|
59
|
+
|
|
60
|
+
# Convert the exception into a structured Throwable object
|
|
61
|
+
throwable = self.destructureException(exception)
|
|
62
|
+
|
|
63
|
+
# If the exception type is in the list of exceptions passed to the handler
|
|
64
|
+
if hasattr(self, 'dont_cathc') and throwable.classtype in self.dont_cathc:
|
|
65
|
+
return
|
|
66
|
+
|
|
67
|
+
# Log the exception details
|
|
68
|
+
log.error(f"[{throwable.classtype.__name__}] {throwable.message}")
|
|
69
|
+
|
|
70
|
+
# Return the structured exception
|
|
71
|
+
return throwable
|
|
72
|
+
|
|
73
|
+
def renderCLI(self, args: List[str], exception: BaseException, log: ILogger, console: IConsole) -> Any:
|
|
74
|
+
"""
|
|
75
|
+
Render the exception message for CLI output.
|
|
76
|
+
|
|
77
|
+
Parameters
|
|
78
|
+
----------
|
|
79
|
+
exception : BaseException
|
|
80
|
+
The exception instance that was caught.
|
|
81
|
+
|
|
82
|
+
Returns
|
|
83
|
+
-------
|
|
84
|
+
None
|
|
85
|
+
"""
|
|
86
|
+
# Ensure the provided object is an exception
|
|
87
|
+
if not isinstance(exception, BaseException):
|
|
88
|
+
raise TypeError(f"Expected BaseException, got {type(exception).__name__}")
|
|
89
|
+
|
|
90
|
+
# Convert the exception into a structured Throwable object
|
|
91
|
+
throwable = self.destructureException(exception)
|
|
92
|
+
|
|
93
|
+
# If the exception type is in the list of exceptions passed to the handler
|
|
94
|
+
if hasattr(self, 'dont_cathc') and throwable.classtype in self.dont_cathc:
|
|
95
|
+
return
|
|
96
|
+
|
|
97
|
+
# Log the CLI error message with arguments
|
|
98
|
+
log.error(f"CLI Error: {throwable.message} (Args: {args})")
|
|
99
|
+
|
|
100
|
+
# Output the exception traceback to the console
|
|
101
|
+
console.newLine()
|
|
102
|
+
console.exception(exception)
|
|
103
|
+
console.newLine()
|
orionis/failure/catch.py
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
from typing import Any, List
|
|
2
|
+
from orionis.console.kernel import KernelCLI
|
|
2
3
|
from orionis.console.output.contracts.console import IConsole
|
|
3
4
|
from orionis.failure.contracts.catch import ICatch
|
|
4
|
-
from orionis.failure.
|
|
5
|
+
from orionis.failure.contracts.handler import IBaseExceptionHandler
|
|
5
6
|
from orionis.foundation.contracts.application import IApplication
|
|
6
7
|
from orionis.services.log.contracts.log_service import ILogger
|
|
7
8
|
|
|
@@ -41,123 +42,52 @@ class Catch(ICatch):
|
|
|
41
42
|
"""
|
|
42
43
|
|
|
43
44
|
# Retrieve the console output service from the application container
|
|
44
|
-
self.
|
|
45
|
+
self.__console: IConsole = app.make('x-orionis.console.output.console')
|
|
45
46
|
|
|
46
47
|
# Retrieve the logger service from the application container
|
|
47
|
-
self.
|
|
48
|
+
self.__logger: ILogger = app.make('x-orionis.services.log.log_service')
|
|
48
49
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
Converts an exception into a structured `Throwable` object containing detailed information.
|
|
52
|
-
|
|
53
|
-
Parameters
|
|
54
|
-
----------
|
|
55
|
-
e : BaseException
|
|
56
|
-
The exception instance to be destructured.
|
|
57
|
-
|
|
58
|
-
Returns
|
|
59
|
-
-------
|
|
60
|
-
Throwable
|
|
61
|
-
A `Throwable` object encapsulating the exception's class type, message, arguments, and traceback.
|
|
62
|
-
|
|
63
|
-
Notes
|
|
64
|
-
-----
|
|
65
|
-
This method extracts the type, message, arguments, and traceback from the provided exception
|
|
66
|
-
and wraps them in a `Throwable` object for consistent error handling and reporting.
|
|
67
|
-
"""
|
|
68
|
-
|
|
69
|
-
# Create and return a Throwable object with detailed exception information
|
|
70
|
-
return Throwable(
|
|
71
|
-
classtype=type(e), # The class/type of the exception
|
|
72
|
-
message=str(e), # The exception message as a string
|
|
73
|
-
args=e.args, # The arguments passed to the exception
|
|
74
|
-
traceback=getattr(e, '__traceback__', None) # The traceback object, if available
|
|
75
|
-
)
|
|
76
|
-
|
|
77
|
-
def report(self, exception: BaseException) -> Any:
|
|
78
|
-
"""
|
|
79
|
-
Logs and returns a destructured representation of an exception.
|
|
80
|
-
|
|
81
|
-
Parameters
|
|
82
|
-
----------
|
|
83
|
-
exception : BaseException
|
|
84
|
-
The exception instance to be reported.
|
|
85
|
-
|
|
86
|
-
Returns
|
|
87
|
-
-------
|
|
88
|
-
Throwable
|
|
89
|
-
A destructured representation of the exception, containing its type, message, arguments, and traceback.
|
|
90
|
-
|
|
91
|
-
Raises
|
|
92
|
-
------
|
|
93
|
-
TypeError
|
|
94
|
-
If the provided exception is not an instance of BaseException.
|
|
50
|
+
# Retrieve the console output service from the application container
|
|
51
|
+
self.__exception_handler: IBaseExceptionHandler = app.getExceptionHandler()
|
|
95
52
|
|
|
96
|
-
|
|
97
|
-
-----
|
|
98
|
-
This method logs the exception details using the configured logger and returns a structured
|
|
99
|
-
representation of the exception for further processing.
|
|
53
|
+
def exception(self, kernel: Any, request: Any, e: BaseException) -> None:
|
|
100
54
|
"""
|
|
55
|
+
Handles and reports exceptions that occur during CLI execution.
|
|
101
56
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
raise TypeError(f"Expected BaseException, got {type(exception).__name__}")
|
|
105
|
-
|
|
106
|
-
# Convert the exception into a structured Throwable object
|
|
107
|
-
throwable = self.destructureException(exception)
|
|
108
|
-
|
|
109
|
-
# If the exception type is in the list of exceptions passed to the handler
|
|
110
|
-
if hasattr(self, 'dont_cathc') and throwable.classtype in self.dont_cathc:
|
|
111
|
-
return
|
|
112
|
-
|
|
113
|
-
# Log the exception details
|
|
114
|
-
self.logger.error(f"[{throwable.classtype.__name__}] {throwable.message}")
|
|
115
|
-
|
|
116
|
-
# Return the structured exception
|
|
117
|
-
return throwable
|
|
118
|
-
|
|
119
|
-
def renderCLI(self, args: List[str], exception: BaseException) -> Any:
|
|
120
|
-
"""
|
|
121
|
-
Renders a CLI-friendly error message for a given exception.
|
|
57
|
+
This method reports the provided exception using the application's exception handler and logger.
|
|
58
|
+
If a kernel instance is provided, it also renders the exception details to the CLI for user visibility.
|
|
122
59
|
|
|
123
60
|
Parameters
|
|
124
61
|
----------
|
|
125
|
-
|
|
126
|
-
The
|
|
127
|
-
|
|
128
|
-
The
|
|
62
|
+
kernel : Any
|
|
63
|
+
The kernel instance associated with the CLI, or None if not available.
|
|
64
|
+
request : Any
|
|
65
|
+
The request or arguments associated with the CLI command.
|
|
66
|
+
e : BaseException
|
|
67
|
+
The exception instance to be handled.
|
|
129
68
|
|
|
130
69
|
Returns
|
|
131
70
|
-------
|
|
132
71
|
None
|
|
133
|
-
This method does not return any value.
|
|
134
|
-
|
|
135
|
-
Raises
|
|
136
|
-
------
|
|
137
|
-
TypeError
|
|
138
|
-
If the provided exception is not an instance of BaseException.
|
|
72
|
+
This method does not return any value. It performs side effects such as logging and output.
|
|
139
73
|
|
|
140
74
|
Notes
|
|
141
75
|
-----
|
|
142
|
-
|
|
143
|
-
the exception
|
|
76
|
+
The exception is always reported using the exception handler and logger.
|
|
77
|
+
If a valid kernel is provided, the exception details are rendered to the CLI.
|
|
144
78
|
"""
|
|
145
79
|
|
|
146
|
-
#
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
throwable = self.destructureException(exception)
|
|
152
|
-
|
|
153
|
-
# If the exception type is in the list of exceptions passed to the handler
|
|
154
|
-
if hasattr(self, 'dont_cathc') and throwable.classtype in self.dont_cathc:
|
|
155
|
-
return
|
|
156
|
-
|
|
157
|
-
# Log the CLI error message with arguments
|
|
158
|
-
self.logger.error(f"CLI Error: {throwable.message} (Args: {args})")
|
|
80
|
+
# Report the exception using the application's exception handler and logger
|
|
81
|
+
self.__exception_handler.report(
|
|
82
|
+
exception=e,
|
|
83
|
+
log=self.__logger
|
|
84
|
+
)
|
|
159
85
|
|
|
160
|
-
#
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
86
|
+
# If a kernel is provided, render the exception details to the CLI
|
|
87
|
+
if isinstance(kernel, KernelCLI):
|
|
88
|
+
return self.__exception_handler.renderCLI(
|
|
89
|
+
args=request,
|
|
90
|
+
exception=e,
|
|
91
|
+
log=self.__logger,
|
|
92
|
+
console=self.__console
|
|
93
|
+
)
|
|
@@ -1,91 +1,32 @@
|
|
|
1
1
|
from abc import ABC, abstractmethod
|
|
2
|
-
from typing import Any
|
|
3
|
-
from orionis.foundation.contracts.application import IApplication
|
|
2
|
+
from typing import Any
|
|
4
3
|
|
|
5
4
|
class ICatch(ABC):
|
|
6
5
|
|
|
7
6
|
@abstractmethod
|
|
8
|
-
def
|
|
7
|
+
def exception(self, kernel: Any, request: Any, e: BaseException) -> None:
|
|
9
8
|
"""
|
|
10
|
-
|
|
9
|
+
Handles and reports exceptions that occur during CLI execution.
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
app : IApplication
|
|
15
|
-
The application instance used to resolve required services.
|
|
16
|
-
|
|
17
|
-
Attributes
|
|
18
|
-
----------
|
|
19
|
-
console : IConsole
|
|
20
|
-
Console output service obtained from the application for displaying messages and exceptions.
|
|
21
|
-
logger : ILogger
|
|
22
|
-
Logger service obtained from the application for logging errors and exceptions.
|
|
23
|
-
|
|
24
|
-
Returns
|
|
25
|
-
-------
|
|
26
|
-
None
|
|
27
|
-
This constructor does not return any value.
|
|
28
|
-
|
|
29
|
-
Notes
|
|
30
|
-
-----
|
|
31
|
-
The constructor retrieves the console and logger services from the application container
|
|
32
|
-
using their respective service keys. These services are used throughout the class for
|
|
33
|
-
error reporting and output.
|
|
34
|
-
"""
|
|
35
|
-
pass
|
|
36
|
-
|
|
37
|
-
@abstractmethod
|
|
38
|
-
def report(self, exception: BaseException) -> Any:
|
|
39
|
-
"""
|
|
40
|
-
Logs and returns a destructured representation of an exception.
|
|
11
|
+
This method reports the provided exception using the application's exception handler and logger.
|
|
12
|
+
If a kernel instance is provided, it also renders the exception details to the CLI for user visibility.
|
|
41
13
|
|
|
42
14
|
Parameters
|
|
43
15
|
----------
|
|
44
|
-
|
|
45
|
-
The
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
A destructured representation of the exception, containing its type, message, arguments, and traceback.
|
|
51
|
-
|
|
52
|
-
Raises
|
|
53
|
-
------
|
|
54
|
-
TypeError
|
|
55
|
-
If the provided exception is not an instance of BaseException.
|
|
56
|
-
|
|
57
|
-
Notes
|
|
58
|
-
-----
|
|
59
|
-
This method logs the exception details using the configured logger and returns a structured
|
|
60
|
-
representation of the exception for further processing.
|
|
61
|
-
"""
|
|
62
|
-
pass
|
|
63
|
-
|
|
64
|
-
@abstractmethod
|
|
65
|
-
def renderCLI(self, args: List[str], exception: BaseException) -> Any:
|
|
66
|
-
"""
|
|
67
|
-
Renders a CLI-friendly error message for a given exception.
|
|
68
|
-
|
|
69
|
-
Parameters
|
|
70
|
-
----------
|
|
71
|
-
args : list
|
|
72
|
-
The list of command-line arguments that were passed to the CLI.
|
|
73
|
-
exception : BaseException
|
|
74
|
-
The exception instance to be rendered.
|
|
16
|
+
kernel : Any
|
|
17
|
+
The kernel instance associated with the CLI, or None if not available.
|
|
18
|
+
request : Any
|
|
19
|
+
The request or arguments associated with the CLI command.
|
|
20
|
+
e : BaseException
|
|
21
|
+
The exception instance to be handled.
|
|
75
22
|
|
|
76
23
|
Returns
|
|
77
24
|
-------
|
|
78
25
|
None
|
|
79
|
-
This method does not return any value.
|
|
80
|
-
|
|
81
|
-
Raises
|
|
82
|
-
------
|
|
83
|
-
TypeError
|
|
84
|
-
If the provided exception is not an instance of BaseException.
|
|
26
|
+
This method does not return any value. It performs side effects such as logging and output.
|
|
85
27
|
|
|
86
28
|
Notes
|
|
87
29
|
-----
|
|
88
|
-
|
|
89
|
-
the exception
|
|
90
|
-
"""
|
|
91
|
-
pass
|
|
30
|
+
The exception is always reported using the exception handler and logger.
|
|
31
|
+
If a valid kernel is provided, the exception details are rendered to the CLI.
|
|
32
|
+
"""
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
from abc import abstractmethod
|
|
2
|
+
from typing import Any, List
|
|
3
|
+
from orionis.console.output.contracts.console import IConsole
|
|
4
|
+
from orionis.services.log.contracts.log_service import ILogger
|
|
5
|
+
|
|
6
|
+
class IBaseExceptionHandler:
|
|
7
|
+
|
|
8
|
+
@abstractmethod
|
|
9
|
+
def report (self, exception: BaseException, log: ILogger) -> Any:
|
|
10
|
+
"""
|
|
11
|
+
Report or log an exception.
|
|
12
|
+
|
|
13
|
+
Parameters
|
|
14
|
+
----------
|
|
15
|
+
exception : BaseException
|
|
16
|
+
The exception instance that was caught.
|
|
17
|
+
|
|
18
|
+
Returns
|
|
19
|
+
-------
|
|
20
|
+
None
|
|
21
|
+
"""
|
|
22
|
+
pass
|
|
23
|
+
|
|
24
|
+
@abstractmethod
|
|
25
|
+
def renderCLI(self, args: List[str], exception: BaseException, log: ILogger, console: IConsole) -> Any:
|
|
26
|
+
"""
|
|
27
|
+
Render the exception message for CLI output.
|
|
28
|
+
|
|
29
|
+
Parameters
|
|
30
|
+
----------
|
|
31
|
+
exception : BaseException
|
|
32
|
+
The exception instance that was caught.
|
|
33
|
+
|
|
34
|
+
Returns
|
|
35
|
+
-------
|
|
36
|
+
None
|
|
37
|
+
"""
|
|
38
|
+
pass
|
|
@@ -2,9 +2,12 @@ import asyncio
|
|
|
2
2
|
import time
|
|
3
3
|
from pathlib import Path
|
|
4
4
|
from typing import Any, List, Type
|
|
5
|
+
from orionis.console.base.contracts.scheduler import IBaseScheduler
|
|
5
6
|
from orionis.console.base.scheduler import BaseScheduler
|
|
6
7
|
from orionis.container.container import Container
|
|
7
8
|
from orionis.container.contracts.service_provider import IServiceProvider
|
|
9
|
+
from orionis.failure.base.handler import BaseExceptionHandler
|
|
10
|
+
from orionis.failure.contracts.handler import IBaseExceptionHandler
|
|
8
11
|
from orionis.foundation.config.app.entities.app import App
|
|
9
12
|
from orionis.foundation.config.auth.entities.auth import Auth
|
|
10
13
|
from orionis.foundation.config.cache.entities.cache import Cache
|
|
@@ -117,6 +120,9 @@ class Application(Container, IApplication):
|
|
|
117
120
|
# Property to store the scheduler instance
|
|
118
121
|
self.__scheduler: BaseScheduler = None
|
|
119
122
|
|
|
123
|
+
# Property to store the exception handler class
|
|
124
|
+
self.__exception_handler: Type[BaseExceptionHandler] = None
|
|
125
|
+
|
|
120
126
|
# Flag to prevent re-initialization
|
|
121
127
|
self.__initialized = True
|
|
122
128
|
|
|
@@ -383,9 +389,88 @@ class Application(Container, IApplication):
|
|
|
383
389
|
# for complex and unique application requirements, supporting advanced customization
|
|
384
390
|
# of every subsystem as needed.
|
|
385
391
|
|
|
392
|
+
def setExceptionHandler(
|
|
393
|
+
self,
|
|
394
|
+
handler: IBaseExceptionHandler
|
|
395
|
+
) -> 'Application':
|
|
396
|
+
"""
|
|
397
|
+
Register a custom exception handler class for the application.
|
|
398
|
+
|
|
399
|
+
This method allows you to specify a custom exception handler class that
|
|
400
|
+
inherits from BaseExceptionHandler. The handler class will be used to
|
|
401
|
+
manage exceptions raised within the application, including reporting and
|
|
402
|
+
rendering error messages. The provided handler must be a class (not an
|
|
403
|
+
instance) and must inherit from BaseExceptionHandler.
|
|
404
|
+
|
|
405
|
+
Parameters
|
|
406
|
+
----------
|
|
407
|
+
handler : Type[BaseExceptionHandler]
|
|
408
|
+
The exception handler class to be used by the application. Must be a
|
|
409
|
+
subclass of BaseExceptionHandler.
|
|
410
|
+
|
|
411
|
+
Returns
|
|
412
|
+
-------
|
|
413
|
+
Application
|
|
414
|
+
The current Application instance, allowing for method chaining.
|
|
415
|
+
|
|
416
|
+
Raises
|
|
417
|
+
------
|
|
418
|
+
OrionisTypeError
|
|
419
|
+
If the provided handler is not a class or is not a subclass of BaseExceptionHandler.
|
|
420
|
+
|
|
421
|
+
Notes
|
|
422
|
+
-----
|
|
423
|
+
The handler is stored internally and will be instantiated when needed.
|
|
424
|
+
This method does not instantiate the handler; it only registers the class.
|
|
425
|
+
"""
|
|
426
|
+
|
|
427
|
+
# Ensure the provided handler is a subclass of BaseExceptionHandler
|
|
428
|
+
if not issubclass(handler, BaseExceptionHandler):
|
|
429
|
+
raise OrionisTypeError(f"Expected BaseExceptionHandler subclass, got {type(handler).__name__}")
|
|
430
|
+
|
|
431
|
+
# Store the handler class in the application for later use
|
|
432
|
+
self.__exception_handler = handler
|
|
433
|
+
|
|
434
|
+
# Return the application instance for method chaining
|
|
435
|
+
return self
|
|
436
|
+
|
|
437
|
+
def getExceptionHandler(
|
|
438
|
+
self
|
|
439
|
+
) -> IBaseExceptionHandler:
|
|
440
|
+
"""
|
|
441
|
+
Retrieve the currently registered exception handler instance.
|
|
442
|
+
|
|
443
|
+
This method returns an instance of the exception handler that has been set using
|
|
444
|
+
the `setExceptionHandler` method. If no custom handler has been set, it returns
|
|
445
|
+
a default `BaseExceptionHandler` instance. The returned object is responsible
|
|
446
|
+
for handling exceptions within the application, including reporting and rendering
|
|
447
|
+
error messages.
|
|
448
|
+
|
|
449
|
+
Returns
|
|
450
|
+
-------
|
|
451
|
+
BaseExceptionHandler
|
|
452
|
+
An instance of the currently registered exception handler. If no handler
|
|
453
|
+
has been set, returns a default `BaseExceptionHandler` instance.
|
|
454
|
+
|
|
455
|
+
Notes
|
|
456
|
+
-----
|
|
457
|
+
This method always returns an instance (not a class) of the exception handler.
|
|
458
|
+
If a custom handler was registered, it is instantiated and returned; otherwise,
|
|
459
|
+
a default handler is used.
|
|
460
|
+
"""
|
|
461
|
+
|
|
462
|
+
# Check if an exception handler has been set
|
|
463
|
+
if self.__exception_handler is None:
|
|
464
|
+
|
|
465
|
+
# Return the default exception handler instance
|
|
466
|
+
return BaseExceptionHandler()
|
|
467
|
+
|
|
468
|
+
# Instantiate and return the registered exception handler
|
|
469
|
+
return self.__exception_handler()
|
|
470
|
+
|
|
386
471
|
def setScheduler(
|
|
387
472
|
self,
|
|
388
|
-
scheduler:
|
|
473
|
+
scheduler: IBaseScheduler
|
|
389
474
|
) -> 'Application':
|
|
390
475
|
"""
|
|
391
476
|
Register a custom scheduler class for the application.
|
|
@@ -430,7 +515,7 @@ class Application(Container, IApplication):
|
|
|
430
515
|
|
|
431
516
|
def getScheduler(
|
|
432
517
|
self
|
|
433
|
-
) ->
|
|
518
|
+
) -> IBaseScheduler:
|
|
434
519
|
"""
|
|
435
520
|
Retrieve the currently registered scheduler instance.
|
|
436
521
|
|
|
@@ -450,7 +535,7 @@ class Application(Container, IApplication):
|
|
|
450
535
|
|
|
451
536
|
# Check if a scheduler has been set
|
|
452
537
|
if self.__scheduler is None:
|
|
453
|
-
|
|
538
|
+
return BaseScheduler()
|
|
454
539
|
|
|
455
540
|
# Return the registered scheduler instance
|
|
456
541
|
return self.__scheduler()
|
|
@@ -2,6 +2,7 @@ from abc import abstractmethod
|
|
|
2
2
|
from pathlib import Path
|
|
3
3
|
from typing import Any, List, Type
|
|
4
4
|
from orionis.console.base.scheduler import BaseScheduler
|
|
5
|
+
from orionis.failure.contracts.handler import IBaseExceptionHandler
|
|
5
6
|
from orionis.foundation.config.roots.paths import Paths
|
|
6
7
|
from orionis.container.contracts.service_provider import IServiceProvider
|
|
7
8
|
from orionis.container.contracts.container import IContainer
|
|
@@ -93,6 +94,68 @@ class IApplication(IContainer):
|
|
|
93
94
|
"""
|
|
94
95
|
pass
|
|
95
96
|
|
|
97
|
+
def setExceptionHandler(
|
|
98
|
+
self,
|
|
99
|
+
handler: IBaseExceptionHandler
|
|
100
|
+
) -> 'IApplication':
|
|
101
|
+
"""
|
|
102
|
+
Register a custom exception handler class for the application.
|
|
103
|
+
|
|
104
|
+
This method allows you to specify a custom exception handler class that
|
|
105
|
+
inherits from BaseHandlerException. The handler class will be used to
|
|
106
|
+
manage exceptions raised within the application, including reporting and
|
|
107
|
+
rendering error messages. The provided handler must be a class (not an
|
|
108
|
+
instance) and must inherit from BaseHandlerException.
|
|
109
|
+
|
|
110
|
+
Parameters
|
|
111
|
+
----------
|
|
112
|
+
handler : Type[BaseHandlerException]
|
|
113
|
+
The exception handler class to be used by the application. Must be a
|
|
114
|
+
subclass of BaseHandlerException.
|
|
115
|
+
|
|
116
|
+
Returns
|
|
117
|
+
-------
|
|
118
|
+
Application
|
|
119
|
+
The current Application instance, allowing for method chaining.
|
|
120
|
+
|
|
121
|
+
Raises
|
|
122
|
+
------
|
|
123
|
+
OrionisTypeError
|
|
124
|
+
If the provided handler is not a class or is not a subclass of BaseHandlerException.
|
|
125
|
+
|
|
126
|
+
Notes
|
|
127
|
+
-----
|
|
128
|
+
The handler is stored internally and will be instantiated when needed.
|
|
129
|
+
This method does not instantiate the handler; it only registers the class.
|
|
130
|
+
"""
|
|
131
|
+
pass
|
|
132
|
+
|
|
133
|
+
def getExceptionHandler(
|
|
134
|
+
self
|
|
135
|
+
) -> IBaseExceptionHandler:
|
|
136
|
+
"""
|
|
137
|
+
Retrieve the currently registered exception handler instance.
|
|
138
|
+
|
|
139
|
+
This method returns an instance of the exception handler that has been set using
|
|
140
|
+
the `setExceptionHandler` method. If no custom handler has been set, it returns
|
|
141
|
+
a default `BaseHandlerException` instance. The returned object is responsible
|
|
142
|
+
for handling exceptions within the application, including reporting and rendering
|
|
143
|
+
error messages.
|
|
144
|
+
|
|
145
|
+
Returns
|
|
146
|
+
-------
|
|
147
|
+
BaseHandlerException
|
|
148
|
+
An instance of the currently registered exception handler. If no handler
|
|
149
|
+
has been set, returns a default `BaseHandlerException` instance.
|
|
150
|
+
|
|
151
|
+
Notes
|
|
152
|
+
-----
|
|
153
|
+
This method always returns an instance (not a class) of the exception handler.
|
|
154
|
+
If a custom handler was registered, it is instantiated and returned; otherwise,
|
|
155
|
+
a default handler is used.
|
|
156
|
+
"""
|
|
157
|
+
pass
|
|
158
|
+
|
|
96
159
|
@abstractmethod
|
|
97
160
|
def setScheduler(
|
|
98
161
|
self,
|
orionis/metadata/framework.py
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
orionis/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
orionis/app.py,sha256=b69fOzj2J8Aw5g0IldWZXixUDeeTO9vcHc_Njses9HU,603
|
|
3
3
|
orionis/console/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
-
orionis/console/kernel.py,sha256=
|
|
4
|
+
orionis/console/kernel.py,sha256=czEZQV-BcL9AV_mNppxCJEz56Hin5ejq1BtXZBSA3Ho,4150
|
|
5
5
|
orionis/console/args/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
6
|
orionis/console/args/argument.py,sha256=Is8Z8_kW4DvcK1nK1UU-sa6Pk0BeOdcRczCayW0ZVHc,20360
|
|
7
7
|
orionis/console/args/enums/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
8
|
orionis/console/args/enums/actions.py,sha256=S3T-vWS6DJSGtANrq3od3-90iYAjPvJwaOZ2V02y34c,1222
|
|
9
9
|
orionis/console/base/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
10
|
orionis/console/base/command.py,sha256=nasVPyKEvuv8sDFEWXhHyBCWAmSLfPPm2XlKaYYt_pM,6642
|
|
11
|
-
orionis/console/base/scheduler.py,sha256=
|
|
11
|
+
orionis/console/base/scheduler.py,sha256=lUHd83YhpsojxcCDme2e9Gcw6ebnsdRFgny4MKH5-rc,3380
|
|
12
12
|
orionis/console/base/contracts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
13
|
orionis/console/base/contracts/command.py,sha256=vmAJD0yMQ5-AD_s9_xCFEAl64sKk65z7U2E196dALQM,5760
|
|
14
14
|
orionis/console/base/contracts/scheduler.py,sha256=y8q4qv6oxjnWSt9G0HP2IjogtWIASfJaMO5vkG22U1Q,1184
|
|
@@ -17,7 +17,7 @@ orionis/console/commands/cache.py,sha256=8DsYoRzSBLn0P9qkGVItRbo0R6snWBDBg0_Xa7t
|
|
|
17
17
|
orionis/console/commands/help.py,sha256=zfSw0pYaOnFN-_Ozdn4veBQDYMgSSDY10nPDCi-7tTY,3199
|
|
18
18
|
orionis/console/commands/publisher.py,sha256=FUg-EUzK7LLXsla10ZUZro8V0Z5S-KjmsaSdRHSSGbA,21381
|
|
19
19
|
orionis/console/commands/scheduler_list.py,sha256=OglphcIhdtWLkUccsINZt7AdWJtu9CE0awA7NkuXXvI,5179
|
|
20
|
-
orionis/console/commands/scheduler_work.py,sha256=
|
|
20
|
+
orionis/console/commands/scheduler_work.py,sha256=QcbVM2gpMV7jqNNpb6lXmDkEajjDso7s8qtjMZ70sOA,5068
|
|
21
21
|
orionis/console/commands/test.py,sha256=-EmQwFwMBuby3OI9HwqMIwuJzd2CGbWbOqmwrR25sOE,2402
|
|
22
22
|
orionis/console/commands/version.py,sha256=SUuNDJ40f2uq69OQUmPQXJKaa9Bm_iVRDPmBd7zc1Yc,3658
|
|
23
23
|
orionis/console/commands/workflow.py,sha256=NYOmjTSvm2o6AE4h9LSTZMFSYPQreNmEJtronyOxaYk,2451
|
|
@@ -93,13 +93,16 @@ orionis/container/validators/is_subclass.py,sha256=4sBaGLoRs8nUhuWjlP0VJqyTwVHYq
|
|
|
93
93
|
orionis/container/validators/is_valid_alias.py,sha256=4uAYcq8xov7jZbXnpKpjNkxcZtlTNnL5RRctVPMwJes,1424
|
|
94
94
|
orionis/container/validators/lifetime.py,sha256=IQ43fDNrxYHMlZH2zlYDJnlkLO_eS4U7Fs3UJgQBidI,1844
|
|
95
95
|
orionis/failure/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
96
|
-
orionis/failure/catch.py,sha256=
|
|
96
|
+
orionis/failure/catch.py,sha256=f3ZUkRJ1OkKnZtFjLu2QWcqka9Bu9rFDb1n1pgRCufg,3608
|
|
97
|
+
orionis/failure/base/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
98
|
+
orionis/failure/base/handler.py,sha256=-Q4v4fO8bhmxgRQeMJ0Afx14zKr68rpOt_vRalAdDYs,3963
|
|
97
99
|
orionis/failure/contracts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
98
|
-
orionis/failure/contracts/catch.py,sha256=
|
|
100
|
+
orionis/failure/contracts/catch.py,sha256=e2wM1p6VxbvAjgWm-MwoM9p2ystSsyBu8Qnt6Ehr6Vc,1179
|
|
101
|
+
orionis/failure/contracts/handler.py,sha256=58rJmj9J_Z-kFWPgtRXd3sjLdEpRMXEmVuXzgHSQGy0,976
|
|
99
102
|
orionis/failure/entities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
100
103
|
orionis/failure/entities/throwable.py,sha256=ogys062uhim5QMYU62ezlnumRAnYQlUf_vZvQY47S3U,1227
|
|
101
104
|
orionis/foundation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
102
|
-
orionis/foundation/application.py,sha256=
|
|
105
|
+
orionis/foundation/application.py,sha256=wiaVt7Y7iDmeZkqs6jK1lgD9C46aqDohmzIMxoFjKZo,81976
|
|
103
106
|
orionis/foundation/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
104
107
|
orionis/foundation/config/startup.py,sha256=vbzduprRCNyYeR2nnMaqc1uKXw6PTzAY2jVfXNQKN8I,9691
|
|
105
108
|
orionis/foundation/config/app/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -193,7 +196,7 @@ orionis/foundation/config/testing/enums/drivers.py,sha256=mwv47FcKDXEOxydQXAGtkd
|
|
|
193
196
|
orionis/foundation/config/testing/enums/mode.py,sha256=IbFpauu7J-iSAfmC8jDbmTEYl8eZr-AexL-lyOh8_74,337
|
|
194
197
|
orionis/foundation/config/testing/enums/verbosity.py,sha256=Z-FQ6C3rxbRwP8HoVibbgRMGcsen2SwTuEy3wnjdIhc,486
|
|
195
198
|
orionis/foundation/contracts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
196
|
-
orionis/foundation/contracts/application.py,sha256=
|
|
199
|
+
orionis/foundation/contracts/application.py,sha256=vLf7ozmdBY3F6pPQipecwo_JbvHshq3jTD4D8YqPy7c,31407
|
|
197
200
|
orionis/foundation/contracts/config.py,sha256=mCyA43f0n_e-CEL0f-sWWgE-M7GicS_aEtC_TNbn_yc,802
|
|
198
201
|
orionis/foundation/exceptions/__init__.py,sha256=q6we1N8kcd6j6GjUJY30WQhhHnqF9RXA0c6-ksEztlc,294
|
|
199
202
|
orionis/foundation/exceptions/integrity.py,sha256=mc4pL1UMoYRHEmphnpW2oGk5URhu7DJRREyzHaV-cs8,472
|
|
@@ -214,7 +217,7 @@ orionis/foundation/providers/scheduler_provider.py,sha256=72SoixFog9IOE9Ve9Xcfw6
|
|
|
214
217
|
orionis/foundation/providers/testing_provider.py,sha256=SrJRpdvcblx9WvX7x9Y3zc7OQfiTf7la0HAJrm2ESlE,3725
|
|
215
218
|
orionis/foundation/providers/workers_provider.py,sha256=oa_2NIDH6UxZrtuGkkoo_zEoNIMGgJ46vg5CCgAm7wI,3926
|
|
216
219
|
orionis/metadata/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
217
|
-
orionis/metadata/framework.py,sha256=
|
|
220
|
+
orionis/metadata/framework.py,sha256=PMZJUhO5FoTMzEhda5DJYJz5RxMTCJjuI2P4wN_z1us,4109
|
|
218
221
|
orionis/metadata/package.py,sha256=k7Yriyp5aUcR-iR8SK2ec_lf0_Cyc-C7JczgXa-I67w,16039
|
|
219
222
|
orionis/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
220
223
|
orionis/services/asynchrony/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -388,7 +391,7 @@ orionis/test/validators/web_report.py,sha256=n9BfzOZz6aEiNTypXcwuWbFRG0OdHNSmCNu
|
|
|
388
391
|
orionis/test/validators/workers.py,sha256=rWcdRexINNEmGaO7mnc1MKUxkHKxrTsVuHgbnIfJYgc,1206
|
|
389
392
|
orionis/test/view/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
390
393
|
orionis/test/view/render.py,sha256=f-zNhtKSg9R5Njqujbg2l2amAs2-mRVESneLIkWOZjU,4082
|
|
391
|
-
orionis-0.
|
|
394
|
+
orionis-0.493.0.dist-info/licenses/LICENCE,sha256=JhC-z_9mbpUrCfPjcl3DhDA8trNDMzb57cvRSam1avc,1463
|
|
392
395
|
tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
393
396
|
tests/container/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
394
397
|
tests/container/context/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -535,8 +538,8 @@ tests/testing/validators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZ
|
|
|
535
538
|
tests/testing/validators/test_testing_validators.py,sha256=WPo5GxTP6xE-Dw3X1vZoqOMpb6HhokjNSbgDsDRDvy4,16588
|
|
536
539
|
tests/testing/view/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
537
540
|
tests/testing/view/test_render.py,sha256=tnnMBwS0iKUIbogLvu-7Rii50G6Koddp3XT4wgdFEYM,1050
|
|
538
|
-
orionis-0.
|
|
539
|
-
orionis-0.
|
|
540
|
-
orionis-0.
|
|
541
|
-
orionis-0.
|
|
542
|
-
orionis-0.
|
|
541
|
+
orionis-0.493.0.dist-info/METADATA,sha256=c-mmJkE34YSSawOWYy0h2iIMHZDhTr__i_LRMi0JExU,4801
|
|
542
|
+
orionis-0.493.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
543
|
+
orionis-0.493.0.dist-info/top_level.txt,sha256=2bdoHgyGZhOtLAXS6Om8OCTmL24dUMC_L1quMe_ETbk,14
|
|
544
|
+
orionis-0.493.0.dist-info/zip-safe,sha256=frcCV1k9oG9oKj3dpUqdJg1PxRT2RSN_XKdLCPjaYaY,2
|
|
545
|
+
orionis-0.493.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|