-
Notifications
You must be signed in to change notification settings - Fork 97
refactor: Centralize error output #3902
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
… link between GEOS_THROW_CTX_IF and LVARRAY_THROW_IF_TEST( EXP, MSG, TYPE )
… in try/catch statements Problem: Retrieves everything that was thrown, so not just the message.
…/catch in main)": remove useless try/catch
…y spaces. The previous condition checked whether an argument was present and whether the option was immediately followed by a value like -test"value", which excluded valid cases like -test "value" et -test "value".
| ErrorLogger::formatMsgToAscii( GEOS_GLOBAL_LOGGER.currentErrorMsg(), \ | ||
| __asciiErrormSG ); \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it really useful to output the message here to the log?
The ErrorMsg get more and more info along the catch potencial cascade, then at the main() catch, it get fully flushed to the YAML. Why not doing the same for the log?
| msgStruct.setCause( __causemsgsoss.str() ); \ | ||
| msgStruct.addCallStackInfo( LvArray::system::stackTrace( true ) ); \ | ||
| msgStruct.addContextInfo( GEOS_DETAIL_REST_ARGS( __VA_ARGS__ ) ); \ | ||
| ErrorLogger::formatMsgToAscii( msgStruct, GEOS_GLOBAL_LOGGER.getErrorStream() ); \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like formatMsgToAscii() should be done internally by flushErrorMsg().
Is it passing the unit test on your side?
Do you have a error/throw/warning test series? (I think you should have like at least 5 tests to validate, but unit tests should do that)
| }; | ||
|
|
||
| /** | ||
| * @brief Retrieve all informations from the ErrorLogger and format into a stream |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * @brief Retrieve all informations from the ErrorLogger and format into a stream | |
| * @brief Retrieve all informations from the ErrorMsg and format into a stream. |
And IF it is needed to be public, you can add:
* Useful for formating a message log text externally.
| else | ||
| { | ||
| GEOS_LOG_RANK( GEOS_FMT( "Unable to open error file for writing.\n- Error file: {}\n- Error file enabled = {}.\n", | ||
| m_filename, g_errorLogger.isOutputFileEnabled() ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
| __FILE__, line1 ), | ||
| "- frame0: ", | ||
| "- frame1: ", | ||
| "- frame2: " | ||
| } ); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Syntax error.
src/main/main.cpp
Outdated
| ErrorLogger::global().getErrorStream() << e.what(); | ||
| ErrorLogger::global().flushErrorMsg( ErrorLogger::global().currentErrorMsg() ); | ||
| LvArray::system::callErrorHandler(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is the right direction (this is related with my other comments).
Remove code duplication found in
GEOS_THROW,GEOS_ERROR,GEOS_WARNINGand put into a static function inErrorLogger.Called while
flushErrorMsg()