SRD errors - Errors, warnings and notes
Replaced the "details" flag with a type which indicates whether an error record contains an actual error, a warning or just a note.
This commit is contained in:
parent
86a3fe34b4
commit
53feddb4ee
3 changed files with 22 additions and 13 deletions
|
@ -116,20 +116,28 @@ M_LSHIFT_OP( T_StringBuilder , T_SRDLocation const& ) noexcept;
|
||||||
|
|
||||||
/*= ERRORS ===================================================================*/
|
/*= ERRORS ===================================================================*/
|
||||||
|
|
||||||
// An error that occurred during SRD processing
|
// Type of an error record
|
||||||
|
enum class E_SRDErrorType {
|
||||||
|
ERROR ,
|
||||||
|
WARNING ,
|
||||||
|
NOTE
|
||||||
|
};
|
||||||
|
|
||||||
|
// An error that occurred during SRD processing. Also includes warnings and
|
||||||
|
// notes.
|
||||||
class T_SRDError
|
class T_SRDError
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
T_String error_;
|
T_String error_;
|
||||||
T_SRDLocation location_;
|
T_SRDLocation location_;
|
||||||
bool isDetails_;
|
E_SRDErrorType type_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
T_SRDError( ) = delete;
|
T_SRDError( ) = delete;
|
||||||
|
|
||||||
T_SRDError( T_String error ,
|
T_SRDError( T_String error ,
|
||||||
T_SRDLocation location ,
|
T_SRDLocation location ,
|
||||||
bool details = false ) noexcept;
|
E_SRDErrorType type = E_SRDErrorType::ERROR ) noexcept;
|
||||||
|
|
||||||
T_SRDError( T_SRDError const& other ) noexcept;
|
T_SRDError( T_SRDError const& other ) noexcept;
|
||||||
T_SRDError& operator= ( T_SRDError const& other ) noexcept;
|
T_SRDError& operator= ( T_SRDError const& other ) noexcept;
|
||||||
|
@ -143,7 +151,7 @@ class T_SRDError
|
||||||
|
|
||||||
T_String const& error( ) const noexcept;
|
T_String const& error( ) const noexcept;
|
||||||
T_SRDLocation const& location( ) const noexcept;
|
T_SRDLocation const& location( ) const noexcept;
|
||||||
bool isDetails( ) const noexcept;
|
E_SRDErrorType type( ) const noexcept;
|
||||||
};
|
};
|
||||||
M_DECLARE_SWAP( T_SRDError );
|
M_DECLARE_SWAP( T_SRDError );
|
||||||
|
|
||||||
|
|
|
@ -117,10 +117,10 @@ inline T_SRDLocationChaining const& T_SRDLocation::chaining( ) const noexcept
|
||||||
inline T_SRDError::T_SRDError(
|
inline T_SRDError::T_SRDError(
|
||||||
T_String error ,
|
T_String error ,
|
||||||
T_SRDLocation location ,
|
T_SRDLocation location ,
|
||||||
const bool details ) noexcept
|
const E_SRDErrorType type ) noexcept
|
||||||
: error_( std::move( error ) ) ,
|
: error_( std::move( error ) ) ,
|
||||||
location_( std::move( location ) ) ,
|
location_( std::move( location ) ) ,
|
||||||
isDetails_( details )
|
type_( type )
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
@ -129,7 +129,7 @@ inline T_SRDError::T_SRDError(
|
||||||
T_SRDError const& other ) noexcept
|
T_SRDError const& other ) noexcept
|
||||||
: error_( other.error_ ) ,
|
: error_( other.error_ ) ,
|
||||||
location_( other.location_ ) ,
|
location_( other.location_ ) ,
|
||||||
isDetails_( other.isDetails_ )
|
type_( other.type_ )
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
inline T_SRDError& T_SRDError::operator= (
|
inline T_SRDError& T_SRDError::operator= (
|
||||||
|
@ -137,7 +137,7 @@ inline T_SRDError& T_SRDError::operator= (
|
||||||
{
|
{
|
||||||
error_ = other.error_;
|
error_ = other.error_;
|
||||||
location_ = other.location_;
|
location_ = other.location_;
|
||||||
isDetails_ = other.isDetails_;
|
type_ = other.type_;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,7 +164,7 @@ inline M_DECLARE_SWAP( T_SRDError )
|
||||||
using std::swap;
|
using std::swap;
|
||||||
swap( lhs.error_ , rhs.error_ );
|
swap( lhs.error_ , rhs.error_ );
|
||||||
swap( lhs.location_ , rhs.location_ );
|
swap( lhs.location_ , rhs.location_ );
|
||||||
swap( lhs.isDetails_ , rhs.isDetails_ );
|
swap( lhs.type_ , rhs.type_ );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
@ -179,9 +179,9 @@ inline T_SRDLocation const& T_SRDError::location( ) const noexcept
|
||||||
return location_;
|
return location_;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool T_SRDError::isDetails( ) const noexcept
|
inline E_SRDErrorType T_SRDError::type( ) const noexcept
|
||||||
{
|
{
|
||||||
return isDetails_;
|
return type_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -104,7 +104,8 @@ T_StringBuilder& ebcl::operator<< (
|
||||||
void T_SRDErrors::checkAdded(
|
void T_SRDErrors::checkAdded(
|
||||||
T_SRDError const& last )
|
T_SRDError const& last )
|
||||||
{
|
{
|
||||||
if ( last.isDetails( ) || errCount_ >= MAX_ERRORS ) {
|
if ( last.type( ) != E_SRDErrorType::ERROR
|
||||||
|
|| errCount_ >= MAX_ERRORS ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
errCount_ ++;
|
errCount_ ++;
|
||||||
|
@ -128,7 +129,7 @@ void T_SRDErrors::addAll(
|
||||||
RPC_SRDLocation lastLocation = nullptr;
|
RPC_SRDLocation lastLocation = nullptr;
|
||||||
for ( uint32_t i = 0 ; i < nErrors ; i ++ ) {
|
for ( uint32_t i = 0 ; i < nErrors ; i ++ ) {
|
||||||
errors_.add( source[ i ] );
|
errors_.add( source[ i ] );
|
||||||
if ( !source[ i ].isDetails( ) ) {
|
if ( source[ i ].type( ) == E_SRDErrorType::ERROR ) {
|
||||||
lastLocation = &source[ i ].location( );
|
lastLocation = &source[ i ].location( );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue