Skip to content

Refactor ErrorHandlerMock #1307

@mossmaurice

Description

@mossmaurice

Brief feature description

Working with the ErrorHandlerMock currently requires some boiler plate code. The code and usage shall be simplified.

Detailed information

From this comment:

It is always the same procedure

  1. set the temporary error handler
  2. store the error code and an error detected flag
  3. check for the error detected and error code

Let's assume we have something like this

auto errorHandlerMock = iox::ErrorHandlerMock<iox::PoshError>;
// do something to trigger the error
ASSERT_TRUE(errorHandlerMock.hasError());
EXPECT_THAT(errorHandlerMock.getError(), Eq(iox::PoshError::Foo)); // assuming we keep the `NO_ERROR`, we could essentially skip the hasError call
EXPECT_THAT(errorHandlerMock.getErrorLevel(), Eq(iox::ErrorLevel::SEVERE));

The ErrorHandlerMock dtor could terminate if hasError is not called, to ensure that the check is done.

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueGood for newcomersrefactoringRefactor code without adding features

    Type

    No type

    Projects

    Status

    To do

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions