btkelly/gandalf

Add a debug mode to the installer

Opened this issue · 1 comments

Add a debug mode to the install process to set a global debug flag for Gandalf. This flag should be used to allow Gandalf to be more error tolerant during release builds. When in debug mode Gandalf should loudly throw exceptions when things are unexpected to allow a developer to resolve the issue easily. When in release mode Gandalf should swallow all exceptions if possible and log them based on the LogLevel set during install. This will remove the possibility of an error in configuration causing the app to crash or block the user from using the app completely.

I like the idea of throwing unchecked exception to the developer user of the library when in debugging mode. However it will make the debugging harder if a production app uses a wrong JSON format, e.g. invalid version code.

Since the BootstrapApi class is already reporting JSON syntax error, and the invalid versionCode can also be categorized to the same error type as "breaking the input contract".

I think it would be a good idea to throwing checked exception and force the developer user to recover from the condition. There can be a new method onError(GandalfException exception) in GandalfCallback. In that way the user can decide in their app to whether allow their user to continue using when Gandalf throws an Error, or any way else.

In the Gandalf, if the BootstarpCallback implementation received a onError call, instead of do nothing, we can directly call gandalfCallback.onError(...) to pass it down to the user to handle.

With that, even in the production app, developer can easily find the cause from the log if their setup in the server didn't trigger the Gandalf properly.