Giri's C++ Support Library
C++ library providing everything you need to quickly create awesome applications.
giri::ExceptionBase Class Reference

Base exception to inherit custom exceptions from. More...

#include <Exception.h>

Inheritance diagram for giri::ExceptionBase:
Collaboration diagram for giri::ExceptionBase:

Public Member Functions

 ExceptionBase (const std::string &msg="")
 
const char * what () const throw ()
 
std::string getMessage () const
 
void setMessage (const std::string &message="")
 

Additional Inherited Members

- Public Types inherited from giri::Object< ExceptionBase >
using SPtr = std::shared_ptr< ExceptionBase >
 
using UPtr = std::unique_ptr< ExceptionBase >
 
using WPtr = std::weak_ptr< ExceptionBase >
 

Detailed Description

Base exception to inherit custom exceptions from.

Example Usage:

#include <Exception.h>
#include <iostream>
class MyException final : public giri::ExceptionBase
{
public:
MyException(const std::string &msg) : ExceptionBase(msg) {};
using SPtr = std::shared_ptr<MyException>;
using UPtr = std::unique_ptr<MyException>;
using WPtr = std::weak_ptr<MyException>;
};
// use exception
int main(int argc, char *argv[]){
try {
throw MyException("My Error Message!");
}
catch (const MyException& e)
{
std::cerr << e.what() << "\n";
}
return EXIT_SUCCESS;
}
Base exception to inherit custom exceptions from.
Base exception to inherit custom exceptions from.
Definition: Exception.h:48
ExceptionBase(const std::string &msg="")
Definition: Exception.h:54

Constructor & Destructor Documentation

◆ ExceptionBase()

giri::ExceptionBase::ExceptionBase ( const std::string &  msg = "")
inline

Constructor takes error message as argument.

Parameters
msgException error message, defaults to empty.

Member Function Documentation

◆ getMessage()

std::string giri::ExceptionBase::getMessage ( ) const
inline

Returns the error message.

Returns
Exception error message.

◆ setMessage()

void giri::ExceptionBase::setMessage ( const std::string &  message = "")
inline

Sets the error message.

Parameters
messageException error message, defaults to empty.

The documentation for this class was generated from the following file: