Skip to content
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

Clean up E57Exception #118

Merged
merged 1 commit into from
Oct 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions include/E57Exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,24 +102,22 @@ namespace e57
{
public:
void report( const char *reportingFileName = nullptr, int reportingLineNumber = 0,
const char *reportingFunctionName = nullptr, std::ostream &os = std::cout ) const;
ErrorCode errorCode() const;
std::string context() const;
const char *reportingFunctionName = nullptr, std::ostream &os = std::cout ) const noexcept;
ErrorCode errorCode() const noexcept;
std::string context() const noexcept;
const char *what() const noexcept override;

// For debugging purposes:
const char *sourceFileName() const;
const char *sourceFunctionName() const;
int sourceLineNumber() const;
const char *sourceFileName() const noexcept;
const char *sourceFunctionName() const noexcept;
int sourceLineNumber() const noexcept;

//! \cond documentNonPublic The following isn't part of the API, and isn't
//! documented.
//! \cond documentNonPublic The following isn't part of the API, and isn't documented.
E57Exception() = delete;
E57Exception( ErrorCode ecode, const std::string &context, const std::string &srcFileName = {},
int srcLineNumber = 0, const char *srcFunctionName = nullptr );
~E57Exception() noexcept override = default;
E57Exception( ErrorCode ecode, std::string context, const char *srcFileName = nullptr, int srcLineNumber = 0,
const char *srcFunctionName = nullptr );

protected:
private:
ErrorCode errorCode_;
std::string context_;
std::string sourceFileName_;
Expand All @@ -133,6 +131,6 @@ namespace e57
// Get latest version of ASTM standard supported, and library id string
E57_DLL void getVersions( int &astmMajor, int &astmMinor, std::string &libraryId );

E57_DLL std::string errorCodeToString( ErrorCode ecode );
E57_DLL std::string errorCodeToString( ErrorCode ecode ) noexcept;
}
}
22 changes: 11 additions & 11 deletions src/E57Exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,12 @@ namespace e57

//! @cond documentNonPublic The following isn't part of the API, and isn't
//! documented.
E57Exception::E57Exception( ErrorCode ecode, const std::string &context, const std::string &srcFileName,
int srcLineNumber, const char *srcFunctionName ) :
E57Exception::E57Exception( ErrorCode ecode, std::string context, const char *srcFileName, int srcLineNumber,
const char *srcFunctionName ) :
errorCode_( ecode ),
context_( context ), sourceFunctionName_( srcFunctionName ), sourceLineNumber_( srcLineNumber )
context_( std::move( context ) ), sourceFileName_( srcFileName ), sourceFunctionName_( srcFunctionName ),
sourceLineNumber_( srcLineNumber )
{
sourceFileName_ = srcFileName.substr( srcFileName.find_last_of( "/\\" ) + 1 );
}
//! @endcond

Expand All @@ -135,7 +135,7 @@ namespace e57
@see E57ExceptionFunctions.cpp example, ErrorCode, HelloWorld.cpp example
*/
void E57Exception::report( const char *reportingFileName, int reportingLineNumber, const char *reportingFunctionName,
std::ostream &os ) const
std::ostream &os ) const noexcept
{
os << "**** Got an e57 exception: " << e57::Utilities::errorCodeToString( errorCode() ) << std::endl;

Expand Down Expand Up @@ -167,7 +167,7 @@ namespace e57
@see E57ExceptionFunctions.cpp example, E57Utilities::errorCodeToString,
ErrorCode
*/
ErrorCode E57Exception::errorCode() const
ErrorCode E57Exception::errorCode() const noexcept
{
return errorCode_;
}
Expand All @@ -184,7 +184,7 @@ namespace e57
@throw No E57Exceptions.
@see E57ExceptionsFunctions.cpp example
*/
std::string E57Exception::context() const
std::string E57Exception::context() const noexcept
{
return context_;
}
Expand Down Expand Up @@ -214,7 +214,7 @@ namespace e57
@throw No E57Exceptions.
@see E57ExceptionsFunctions.cpp example
*/
const char *E57Exception::sourceFileName() const
const char *E57Exception::sourceFileName() const noexcept
{
return sourceFileName_.c_str();
}
Expand All @@ -231,7 +231,7 @@ namespace e57
debugging.
@throw No E57Exceptions.
*/
const char *E57Exception::sourceFunctionName() const
const char *E57Exception::sourceFunctionName() const noexcept
{
return sourceFunctionName_;
}
Expand All @@ -248,7 +248,7 @@ namespace e57
debugging.
@throw No E57Exceptions.
*/
int E57Exception::sourceLineNumber() const
int E57Exception::sourceLineNumber() const noexcept
{
return sourceLineNumber_;
}
Expand Down Expand Up @@ -292,7 +292,7 @@ namespace e57
@throw No E57Exceptions.
@see E57Exception::errorCode
*/
std::string Utilities::errorCodeToString( ErrorCode ecode )
std::string Utilities::errorCodeToString( ErrorCode ecode ) noexcept
{
switch ( ecode )
{
Expand Down