Ticket #180 (assigned Defect: null)
Calls to Logger.LogExceptionAsError should usually not report additional error messages
| Reported by: | jjr8 | Owned by: | jjr8 |
|---|---|---|---|
| Priority: | Medium | Milestone: | Unscheduled |
| Component: | Core - Other | Version: | 0.4 |
| Keywords: | Cc: |
Description
Many GeoEco methods wrap their main processing in a try/except block that calls Logger.LogExceptionAsError in the except handler. This is good. But they usually call that method with an additional log message. This causes the tool to report an "The following consequences resulted from the original error:" followed by the additional error message. As the stack unwinds, higher level methods do the same thing in their own except handlers, resulting in additional errors.
For example:
Extracting SDS "asdf" from HDF file C:\temp7\test.bin to binary file C:\temp7\test2.bin... hdp.exe: hdp.exe: HDP ERROR>>> in dsd: C:\temp7\test.bin is not an HDF file. hdp.exe: hdp.exe: HDP ERROR>>> in do_dumpsds: dsd failed. RuntimeError: hdp.exe returned exit code 1, indicating failure. The following consequences resulted from the original error: Execution of C:\Python25\lib\site-packages\GeoEco\Bin\win32\hdp.exe failed. Could not extract SDS "asdf" from HDF file C:\temp7\test.bin to binary file C:\temp7\test2.bin
The original design was intended to provide as much information as possible. I imagined scenarios where something failed very deep in the stack and the resulting error message had nothing to do with the complex operation being orchestrated further up in the stack. As the stack unwound, the additional error messages were supposed to show how the deep failure related to the higher level operations.
I now think this design does not provide much value. Most of the time, the low-level failure message does include enough information that a reasonably skilled user could figure out how to fix it. In this case, the additional error messages simply fill up the screen with intimidating text that distracts the user from the root problem. In the case of low-level messages that lack detail, the user often does not have much chance at resolving the problem anyway, unless they have a very high level of skill and turn on the debug logging.
The calls to Logger.LogExceptionAsError should be reviewed, and most of them should be changed to not report additional error messages. In the example above, the output is compressed to:
Extracting SDS "asdf" from HDF file C:\temp7\test.bin to binary file C:\temp7\test2.bin... hdp.exe: hdp.exe: HDP ERROR>>> in dsd: C:\temp7\test.bin is not an HDF file. hdp.exe: hdp.exe: HDP ERROR>>> in do_dumpsds: dsd failed. RuntimeError: hdp.exe returned exit code 1, indicating failure.
