This repository has been archived by the owner on Oct 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
libtool: extend and refactor error/warning API, add some basic tests,
add iterator functionality for Warnings to Error class
- Loading branch information
Showing
16 changed files
with
711 additions
and
300 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#ifndef ELEKTRA_BASENOTIFICATION_HPP | ||
#define ELEKTRA_BASENOTIFICATION_HPP | ||
|
||
#include <string> | ||
#include <key.hpp> | ||
#include <utility> | ||
#include <kdberrors.h> // for kdb-types, code and description constants | ||
|
||
namespace kdb | ||
{ | ||
namespace tools | ||
{ | ||
namespace errors | ||
{ | ||
/* common abstract class for warnings and errors */ | ||
/* Because warning and errors share the same data members, a method can accept a ErrBase argument and the caller | ||
* can create an Error or a Warning based on the provided object. */ | ||
class BaseNotification | ||
{ | ||
public: | ||
/* setters */ | ||
void setData (const std::string & reason, const std::string & module, const std::string & file, kdb::long_t line); | ||
|
||
/* get references (for getting and setting member values) */ | ||
std::string & reason(); | ||
std::string & module(); | ||
std::string & file(); | ||
kdb::long_t & line(); | ||
|
||
/* fixed values per Class, taken from C-makro definitions in /src/include/kdberrors.h */ | ||
virtual std::string code() const = 0; | ||
virtual std::string description() const = 0; | ||
|
||
/* string representation */ | ||
friend std::ostream& operator<< (std::ostream& outputStream, const BaseNotification& eb); | ||
/* compare */ | ||
friend bool operator== (const BaseNotification& lhs, const BaseNotification& rhs); | ||
|
||
protected: | ||
BaseNotification () = default; | ||
BaseNotification (const std::string & reason, const std::string & module, const std::string & file, kdb::long_t line); | ||
|
||
/* Can be overwritten by subclasses to change the text representation */ | ||
std::ostream& toString (std::ostream& outputStream) const; | ||
|
||
private: | ||
std::string m_reason; | ||
std::string m_module; | ||
std::string m_file; | ||
kdb::long_t m_line = 0; | ||
}; | ||
|
||
} // namespace errors | ||
} // namespace tools | ||
} // namespace kdb | ||
#endif // ELEKTRA_BASENOTIFICATION_HPP |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
|
||
#ifndef ELEKTRA_ERRORTYPES_HPP | ||
#define ELEKTRA_ERRORTYPES_HPP | ||
|
||
#include "error.hpp" | ||
|
||
namespace kdb | ||
{ | ||
namespace tools | ||
{ | ||
namespace errors | ||
{ | ||
|
||
/* This file contains all concrete classes for the different Errors, based on the constants defined in /src/include/kdberrors.h */ | ||
|
||
class ResourceError : public Error | ||
{ | ||
public: | ||
ResourceError (const std::string & reason, const std::string & module, const std::string & file, kdb::long_t line) | ||
: Error { reason, module, file, line} {} | ||
|
||
std::string code() const override; | ||
std::string description() const override; | ||
}; | ||
|
||
class OutOfMemoryError : public Error | ||
{ | ||
public: | ||
OutOfMemoryError (const std::string & reason, const std::string & module, const std::string & file, kdb::long_t line) | ||
: Error { reason, module, file, line} {} | ||
|
||
std::string code() const override; | ||
std::string description() const override; | ||
}; | ||
|
||
class InstallationError : public Error | ||
{ | ||
public: | ||
InstallationError (const std::string & reason, const std::string & module, const std::string & file, kdb::long_t line) | ||
: Error { reason, module, file, line} {} | ||
|
||
std::string code() const override; | ||
std::string description() const override; | ||
}; | ||
|
||
|
||
class InternalError: public Error | ||
{ | ||
public: | ||
InternalError (const std::string & reason, const std::string & module, const std::string & file, kdb::long_t line) | ||
: Error { reason, module, file, line} {} | ||
|
||
std::string code() const override; | ||
std::string description() const override; | ||
}; | ||
|
||
class InterfaceError : public Error | ||
{ | ||
public: | ||
InterfaceError (const std::string & reason, const std::string & module, const std::string & file, kdb::long_t line) | ||
: Error { reason, module, file, line} {} | ||
|
||
std::string code() const override; | ||
std::string description() const override; | ||
}; | ||
|
||
class PluginMisbehaviorError : public Error | ||
{ | ||
public: | ||
PluginMisbehaviorError (const std::string & reason, const std::string & module, const std::string & file, kdb::long_t line) | ||
: Error { reason, module, file, line} {} | ||
|
||
std::string code() const override; | ||
std::string description() const override; | ||
}; | ||
|
||
class ConflictingStateError : public Error | ||
{ | ||
public: | ||
ConflictingStateError (const std::string & reason, const std::string & module, const std::string & file, kdb::long_t line) | ||
: Error { reason, module, file, line} {} | ||
|
||
std::string code() const override; | ||
std::string description() const override; | ||
}; | ||
|
||
class ValidationSyntacticError : public Error | ||
{ | ||
public: | ||
ValidationSyntacticError (const std::string & reason, const std::string & module, const std::string & file, kdb::long_t line) | ||
: Error { reason, module, file, line} {} | ||
|
||
std::string code() const override; | ||
std::string description() const override; | ||
}; | ||
|
||
class ValidationSemanticError : public Error | ||
{ | ||
public: | ||
ValidationSemanticError (const std::string & reason, const std::string & module, const std::string & file, kdb::long_t line) | ||
: Error { reason, module, file, line} {} | ||
|
||
std::string code() const override; | ||
std::string description() const override; | ||
}; | ||
|
||
} // namespace errors | ||
} // namespace tools | ||
} // namespace kdb | ||
|
||
#endif // ELEKTRA_ERRORTYPES_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.