add exceptions

This commit is contained in:
lucaspalomodevelop 2023-10-03 17:01:11 +02:00
parent 71cc0708ae
commit 4efa8bd9d4
7 changed files with 100 additions and 1 deletions

4
.gitignore vendored
View File

@ -1,2 +1,4 @@
main.cpp
*.exe
*.exe
*.out
.vscode

View File

@ -2,7 +2,10 @@
#ifndef __LPSTD_HPP__
#define __LPSTD_HPP__
#include "src/patterns/singleton.hpp"
#include "src/testing/testing.hpp"
// #include "src/faker/faker.hpp"
#include "src/exceptions/exceptions.hpp"
#endif // __LPSTD_HPP__

View File

@ -0,0 +1,7 @@
#ifndef EXCEPTIONS_HPP
#define EXCEPTIONS_HPP
#include "generic_exception.hpp"
#include "notImplementedException.hpp"
#endif // EXCEPTIONS_HPP

View File

@ -0,0 +1,32 @@
#ifndef GENERIC_EXCEPTION_HPP
#define GENERIC_EXCEPTION_HPP
#include <exception>
#include <string>
namespace lpstd
{
namespace exceptions
{
class generic_exception : public std::exception
{
private:
std::string message;
public:
generic_exception(std::string message)
{
this->message = message;
}
const char *what() const throw()
{
return this->message.c_str();
}
};
}
} // namespace lpstd::
#endif // GENERIC_EXCEPTION_HPP

View File

@ -0,0 +1,22 @@
#ifndef NotImplementedException_HPP
#define NotImplementedException_HPP
#include "generic_exception.hpp"
namespace lpstd
{
namespace exceptions
{
class NotImplementedException : public generic_exception
{
public:
NotImplementedException() : generic_exception("Not implemented exception")
{
}
};
} // namespace exceptions
} // namespace lpstd
#endif // NotImplementedException_HPP

6
src/faker/faker.hpp Normal file
View File

@ -0,0 +1,6 @@
#ifndef FAKER_HPP
#define FAKER_HPP
#include "./file.hpp"
#endif // FAKER_HPP

27
src/faker/file.hpp Normal file
View File

@ -0,0 +1,27 @@
#ifndef FAKER_FILE_HPP
#define FAKER_FILE_HPP
#include <string>
namespace lpstd
{
namespace faker
{
class file
{
public:
std::string virtualPath;
file()
{
this->virtualPath = "C:\\Users\\Public\\Documents\\lpstd\\faker\\file.txt";
}
std::ofstream get_ofStream()
{
std::ofstream file;
file.open(this->virtualPath);
return file;
}
};
} // namespace faker
} // namespace lpstd
#endif // FAKER_FILE_HPP