Open wildbiotiger opened 11 months ago
@wildbiotiger I understand your request. I think your suggestion an overrideable exit handler is a good one. Let me discuss with some colleagues. I'll keep you posted.
@wildbiotiger my colleagues agree with the suggestion of providing an overrideable exit handler. I'll let you know as we develop this.
@wildbiotiger I just pushed a branch called error-handler-class. You'll see that all calls to exit() are replaced by calls to cbErrors.handle(). As per your suggestion 'handle' simply does the 'exit' by default. If you want to override what 'handle' does, then add this to your code:
from clearblade.ClearBladeCore import System, cbErrors
class YourErrorHandler(cbErrors.ErrorHandler):
def handle(self, code):
# your custom error handling goes here. Call the super 'handle' (below) if needed
# super().handle(code)
print("custom error handling")
cbErrors.ERROR_HANDLER = YourErrorHandler()
...
Again, to run from the source code of the branch then clone the branch and add this before the 'import' statement above:
import sys
path_to_clearblade_module = "/path/to/your/clone"
sys.path.insert(0, path_to_clearblade_module)
Please try this and let me know if this matches your suggestion.
@wildbiotiger did you have a chance to try this branch? Did it work? If so I would like to merge it.
Inside ClearBladeCore.py, there are several direct calls to
exit()
on invalid authentication. While these can be caught bySystemExit
, could the result be changed to a more friendly exception model? This would allow a more graceful bailout of the system left to the implementer to decide rather than a full application exit.Even simpler, an exit callback that defaults to
exit()
but can be overridden with an option.