Skip to content

Commit

Permalink
dev: Rename return code vars
Browse files Browse the repository at this point in the history
  • Loading branch information
KonradBkd committed Dec 17, 2024
1 parent 643d74e commit a693835
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 42 deletions.
16 changes: 8 additions & 8 deletions SilKit/include/silkit/capi/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ typedef int32_t SilKit_ReturnCode;
// exception and thrown in ThrowOnError.hpp.

#define SilKit_ReturnCode_WRONGSTATE ((SilKit_ReturnCode)8) // SilKit::StateError
#define SilKit_ReturnCode_TYPECONVERSION_ERROR ((SilKit_ReturnCode)9) // SilKit::TypeConversionError
#define SilKit_ReturnCode_CONFIGURATION_ERROR ((SilKit_ReturnCode)10) // SilKit::ConfigurationError
#define SilKit_ReturnCode_PROTOCOL_ERROR ((SilKit_ReturnCode)11) // SilKit::ProtocolError
#define SilKit_ReturnCode_ASSERTION_ERROR ((SilKit_ReturnCode)12) // SilKit::AssertionError
#define SilKit_ReturnCode_EXTENSION_ERROR ((SilKit_ReturnCode)13) // SilKit::ExtensionError
#define SilKit_ReturnCode_LOGIC_ERROR ((SilKit_ReturnCode)14) // SilKit::LogicError
#define SilKit_ReturnCode_LENGTH_ERROR ((SilKit_ReturnCode)15) // SilKit::LengthError
#define SilKit_ReturnCode_OUTOFRANGE_ERROR ((SilKit_ReturnCode)16) // SilKit::OutOfRangeError
#define SilKit_ReturnCode_TYPECONVERSIONERROR ((SilKit_ReturnCode)9) // SilKit::TypeConversionError
#define SilKit_ReturnCode_CONFIGURATIONERROR ((SilKit_ReturnCode)10) // SilKit::ConfigurationError
#define SilKit_ReturnCode_PROTOCOLERROR ((SilKit_ReturnCode)11) // SilKit::ProtocolError
#define SilKit_ReturnCode_ASSERTIONERROR ((SilKit_ReturnCode)12) // SilKit::AssertionError
#define SilKit_ReturnCode_EXTENSIONERROR ((SilKit_ReturnCode)13) // SilKit::ExtensionError
#define SilKit_ReturnCode_LOGICERROR ((SilKit_ReturnCode)14) // SilKit::LogicError
#define SilKit_ReturnCode_LENGTHERROR ((SilKit_ReturnCode)15) // SilKit::LengthError
#define SilKit_ReturnCode_OUTOFRANGEERROR ((SilKit_ReturnCode)16) // SilKit::OutOfRangeError

typedef uint64_t SilKit_NanosecondsTime;

Expand Down
16 changes: 8 additions & 8 deletions SilKit/include/silkit/detail/impl/ThrowOnError.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,21 @@ void ThrowOnError(SilKit_ReturnCode returnCode)
{
case SilKit_ReturnCode_WRONGSTATE:
throw StateError{os.str()};
case SilKit_ReturnCode_TYPECONVERSION_ERROR:
case SilKit_ReturnCode_TYPECONVERSIONERROR:
throw TypeConversionError{os.str()};
case SilKit_ReturnCode_CONFIGURATION_ERROR:
case SilKit_ReturnCode_CONFIGURATIONERROR:
throw ConfigurationError{os.str()};
case SilKit_ReturnCode_PROTOCOL_ERROR:
case SilKit_ReturnCode_PROTOCOLERROR:
throw ProtocolError{os.str()};
case SilKit_ReturnCode_ASSERTION_ERROR:
case SilKit_ReturnCode_ASSERTIONERROR:
throw AssertionError{os.str()};
case SilKit_ReturnCode_EXTENSION_ERROR:
case SilKit_ReturnCode_EXTENSIONERROR:
throw ExtensionError{os.str()};
case SilKit_ReturnCode_LOGIC_ERROR:
case SilKit_ReturnCode_LOGICERROR:
throw LogicError{os.str()};
case SilKit_ReturnCode_LENGTH_ERROR:
case SilKit_ReturnCode_LENGTHERROR:
throw LengthError{os.str()};
case SilKit_ReturnCode_OUTOFRANGE_ERROR:
case SilKit_ReturnCode_OUTOFRANGEERROR:
throw OutOfRangeError{os.str()};
default:
throw SilKitError{os.str()};
Expand Down
16 changes: 8 additions & 8 deletions SilKit/source/capi/CapiImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,42 +42,42 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
catch (const SilKit::TypeConversionError& e) \
{ \
SilKit_error_string = e.what(); \
return SilKit_ReturnCode_TYPECONVERSION_ERROR; \
return SilKit_ReturnCode_TYPECONVERSIONERROR; \
} \
catch (const SilKit::ConfigurationError& e) \
{ \
SilKit_error_string = e.what(); \
return SilKit_ReturnCode_CONFIGURATION_ERROR; \
return SilKit_ReturnCode_CONFIGURATIONERROR; \
} \
catch (const SilKit::ProtocolError& e) \
{ \
SilKit_error_string = e.what(); \
return SilKit_ReturnCode_PROTOCOL_ERROR; \
return SilKit_ReturnCode_PROTOCOLERROR; \
} \
catch (const SilKit::AssertionError& e) \
{ \
SilKit_error_string = e.what(); \
return SilKit_ReturnCode_ASSERTION_ERROR; \
return SilKit_ReturnCode_ASSERTIONERROR; \
} \
catch (const SilKit::ExtensionError& e) \
{ \
SilKit_error_string = e.what(); \
return SilKit_ReturnCode_EXTENSION_ERROR; \
return SilKit_ReturnCode_EXTENSIONERROR; \
} \
catch (const SilKit::LengthError& e) \
{ \
SilKit_error_string = e.what(); \
return SilKit_ReturnCode_LENGTH_ERROR; \
return SilKit_ReturnCode_LENGTHERROR; \
} \
catch (const SilKit::OutOfRangeError& e) \
{ \
SilKit_error_string = e.what(); \
return SilKit_ReturnCode_OUTOFRANGE_ERROR; \
return SilKit_ReturnCode_OUTOFRANGEERROR; \
} \
catch (const SilKit::LogicError& e) \
{ \
SilKit_error_string = e.what(); \
return SilKit_ReturnCode_LOGIC_ERROR; \
return SilKit_ReturnCode_LOGICERROR; \
} \
catch (const SilKit::SilKitError& e) \
{ \
Expand Down
32 changes: 16 additions & 16 deletions SilKit/source/capi/Test_CapiExceptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ TEST_F(Test_CapiExceptions, catch_exception_macro)
{
EXPECT_EQ(TestExceptionToErrorCode<SilKit::CapiBadParameterError>(), SilKit_ReturnCode_BADPARAMETER);

EXPECT_EQ(TestExceptionToErrorCode<SilKit::TypeConversionError>(), SilKit_ReturnCode_TYPECONVERSION_ERROR);
EXPECT_EQ(TestExceptionToErrorCode<SilKit::ConfigurationError>(), SilKit_ReturnCode_CONFIGURATION_ERROR);
EXPECT_EQ(TestExceptionToErrorCode<SilKit::TypeConversionError>(), SilKit_ReturnCode_TYPECONVERSIONERROR);
EXPECT_EQ(TestExceptionToErrorCode<SilKit::ConfigurationError>(), SilKit_ReturnCode_CONFIGURATIONERROR);
EXPECT_EQ(TestExceptionToErrorCode<SilKit::StateError>(), SilKit_ReturnCode_WRONGSTATE);
EXPECT_EQ(TestExceptionToErrorCode<SilKit::ProtocolError>(), SilKit_ReturnCode_PROTOCOL_ERROR);
EXPECT_EQ(TestExceptionToErrorCode<SilKit::AssertionError>(), SilKit_ReturnCode_ASSERTION_ERROR);
EXPECT_EQ(TestExceptionToErrorCode<SilKit::ExtensionError>(), SilKit_ReturnCode_EXTENSION_ERROR);
EXPECT_EQ(TestExceptionToErrorCode<SilKit::LogicError>(), SilKit_ReturnCode_LOGIC_ERROR);
EXPECT_EQ(TestExceptionToErrorCode<SilKit::LengthError>(), SilKit_ReturnCode_LENGTH_ERROR);
EXPECT_EQ(TestExceptionToErrorCode<SilKit::OutOfRangeError>(), SilKit_ReturnCode_OUTOFRANGE_ERROR);
EXPECT_EQ(TestExceptionToErrorCode<SilKit::ProtocolError>(), SilKit_ReturnCode_PROTOCOLERROR);
EXPECT_EQ(TestExceptionToErrorCode<SilKit::AssertionError>(), SilKit_ReturnCode_ASSERTIONERROR);
EXPECT_EQ(TestExceptionToErrorCode<SilKit::ExtensionError>(), SilKit_ReturnCode_EXTENSIONERROR);
EXPECT_EQ(TestExceptionToErrorCode<SilKit::LogicError>(), SilKit_ReturnCode_LOGICERROR);
EXPECT_EQ(TestExceptionToErrorCode<SilKit::LengthError>(), SilKit_ReturnCode_LENGTHERROR);
EXPECT_EQ(TestExceptionToErrorCode<SilKit::OutOfRangeError>(), SilKit_ReturnCode_OUTOFRANGEERROR);

EXPECT_EQ(TestExceptionToErrorCode<SilKit::SilKitError>(), SilKit_ReturnCode_UNSPECIFIEDERROR);
EXPECT_EQ(TestExceptionToErrorCode<std::runtime_error>(), SilKit_ReturnCode_UNSPECIFIEDERROR);
Expand All @@ -80,16 +80,16 @@ TEST_F(Test_CapiExceptions, catch_exception_macro)
// Test that the C-API return code results in the correct exception
TEST_F(Test_CapiExceptions, throw_on_error)
{
EXPECT_THROW(SilKit::_detail_v1::Impl::ThrowOnError(SilKit_ReturnCode_TYPECONVERSION_ERROR),
EXPECT_THROW(SilKit::_detail_v1::Impl::ThrowOnError(SilKit_ReturnCode_TYPECONVERSIONERROR),
SilKit::TypeConversionError);
EXPECT_THROW(SilKit::_detail_v1::Impl::ThrowOnError(SilKit_ReturnCode_CONFIGURATION_ERROR), SilKit::ConfigurationError);
EXPECT_THROW(SilKit::_detail_v1::Impl::ThrowOnError(SilKit_ReturnCode_CONFIGURATIONERROR), SilKit::ConfigurationError);
EXPECT_THROW(SilKit::_detail_v1::Impl::ThrowOnError(SilKit_ReturnCode_WRONGSTATE), SilKit::StateError);
EXPECT_THROW(SilKit::_detail_v1::Impl::ThrowOnError(SilKit_ReturnCode_PROTOCOL_ERROR), SilKit::ProtocolError);
EXPECT_THROW(SilKit::_detail_v1::Impl::ThrowOnError(SilKit_ReturnCode_ASSERTION_ERROR), SilKit::AssertionError);
EXPECT_THROW(SilKit::_detail_v1::Impl::ThrowOnError(SilKit_ReturnCode_EXTENSION_ERROR), SilKit::ExtensionError);
EXPECT_THROW(SilKit::_detail_v1::Impl::ThrowOnError(SilKit_ReturnCode_LOGIC_ERROR), SilKit::LogicError);
EXPECT_THROW(SilKit::_detail_v1::Impl::ThrowOnError(SilKit_ReturnCode_LENGTH_ERROR), SilKit::LengthError);
EXPECT_THROW(SilKit::_detail_v1::Impl::ThrowOnError(SilKit_ReturnCode_OUTOFRANGE_ERROR), SilKit::OutOfRangeError);
EXPECT_THROW(SilKit::_detail_v1::Impl::ThrowOnError(SilKit_ReturnCode_PROTOCOLERROR), SilKit::ProtocolError);
EXPECT_THROW(SilKit::_detail_v1::Impl::ThrowOnError(SilKit_ReturnCode_ASSERTIONERROR), SilKit::AssertionError);
EXPECT_THROW(SilKit::_detail_v1::Impl::ThrowOnError(SilKit_ReturnCode_EXTENSIONERROR), SilKit::ExtensionError);
EXPECT_THROW(SilKit::_detail_v1::Impl::ThrowOnError(SilKit_ReturnCode_LOGICERROR), SilKit::LogicError);
EXPECT_THROW(SilKit::_detail_v1::Impl::ThrowOnError(SilKit_ReturnCode_LENGTHERROR), SilKit::LengthError);
EXPECT_THROW(SilKit::_detail_v1::Impl::ThrowOnError(SilKit_ReturnCode_OUTOFRANGEERROR), SilKit::OutOfRangeError);
EXPECT_THROW(SilKit::_detail_v1::Impl::ThrowOnError(SilKit_ReturnCode_UNSPECIFIEDERROR), SilKit::SilKitError);
}

Expand Down
4 changes: 2 additions & 2 deletions SilKit/source/capi/Test_CapiSilKit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ TEST_F(Test_CapiSilKit, silkit_bad_params)

returnCode =
SilKit_ParticipantConfiguration_FromString(&participantConfigFromString, SILKIT_MALFORMED_CONFIG_STRING);
EXPECT_EQ(returnCode, SilKit_ReturnCode_CONFIGURATION_ERROR);
EXPECT_EQ(returnCode, SilKit_ReturnCode_CONFIGURATIONERROR);
EXPECT_EQ(participantConfigFromString, nullptr);
}

Expand All @@ -87,7 +87,7 @@ TEST_F(Test_CapiSilKit, silkit_bad_params)

returnCode =
SilKit_ParticipantConfiguration_FromFile(&participantConfigFromFile, "this_file_does_not_exist.yaml");
EXPECT_EQ(returnCode, SilKit_ReturnCode_CONFIGURATION_ERROR);
EXPECT_EQ(returnCode, SilKit_ReturnCode_CONFIGURATIONERROR);
EXPECT_TRUE(participantConfigFromFile == nullptr);
}

Expand Down

0 comments on commit a693835

Please sign in to comment.