-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework all exceptions and fix negative zeroes in RealFunctions
- Loading branch information
Showing
143 changed files
with
4,981 additions
and
1,919 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
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 |
---|---|---|
@@ -1,14 +1,21 @@ | ||
#pragma once | ||
|
||
#include <exception> | ||
#include <string> | ||
#include <utility> | ||
|
||
namespace fintamath { | ||
|
||
class Exception : public std::exception { | ||
public: | ||
explicit Exception(std::string inMessage) noexcept : message(std::move(inMessage)) {} | ||
|
||
const char *what() const noexcept override { | ||
return "Something went wrong..."; | ||
return message.data(); | ||
} | ||
|
||
private: | ||
std::string message; | ||
}; | ||
|
||
} |
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 |
---|---|---|
@@ -1,75 +1,15 @@ | ||
#pragma once | ||
|
||
#include <cstdint> | ||
#include <string> | ||
#include <vector> | ||
#include <utility> | ||
|
||
#include "fintamath/exceptions/Exception.hpp" | ||
|
||
namespace fintamath { | ||
|
||
class InvalidInputException : public Exception { | ||
public: | ||
InvalidInputException() noexcept = default; | ||
|
||
explicit InvalidInputException(const std::string &input) noexcept { | ||
content += ": " + input; | ||
} | ||
|
||
const char *what() const noexcept override { | ||
return content.c_str(); | ||
} | ||
|
||
protected: | ||
std::string content = "Invalid input"; | ||
}; | ||
|
||
class InvalidInputFunctionException final : public InvalidInputException { | ||
public: | ||
explicit InvalidInputFunctionException(const std::string &func, const std::vector<std::string> &argVect) noexcept { | ||
content += ": " + func + "("; | ||
|
||
if (!argVect.empty()) { | ||
for (const auto &arg : argVect) { | ||
content += arg + ','; | ||
} | ||
|
||
content.pop_back(); | ||
} | ||
|
||
content += ")"; | ||
} | ||
|
||
const char *what() const noexcept override { | ||
return content.c_str(); | ||
} | ||
}; | ||
|
||
class InvalidInputBinaryOperatorException final : public InvalidInputException { | ||
public: | ||
explicit InvalidInputBinaryOperatorException(const std::string &oper, const std::string &lhs, const std::string &rhs) noexcept { | ||
content += ": (" + lhs + ")" + oper + "(" + rhs + ")"; | ||
} | ||
}; | ||
|
||
class InvalidInputUnaryOperatorException final : public InvalidInputException { | ||
public: | ||
enum class Type : uint8_t { | ||
Prefix, | ||
Postfix, | ||
}; | ||
|
||
public: | ||
explicit InvalidInputUnaryOperatorException(const std::string &oper, const std::string &rhs, const Type type) noexcept { | ||
switch (type) { | ||
case Type::Prefix: | ||
content += ": " + oper + "(" + rhs + ")"; | ||
break; | ||
case Type::Postfix: | ||
content += ": (" + rhs + ")" + oper; | ||
break; | ||
} | ||
} | ||
explicit InvalidInputException(std::string inMessage) noexcept : Exception(std::move(inMessage)) {} | ||
}; | ||
|
||
} |
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 |
---|---|---|
@@ -1,75 +1,15 @@ | ||
#pragma once | ||
|
||
#include <cstdint> | ||
#include <string> | ||
#include <vector> | ||
#include <utility> | ||
|
||
#include "fintamath/exceptions/Exception.hpp" | ||
|
||
namespace fintamath { | ||
|
||
class UndefinedException : public Exception { | ||
public: | ||
UndefinedException() noexcept = default; | ||
|
||
explicit UndefinedException(const std::string &input) noexcept { | ||
content += ": " + input; | ||
} | ||
|
||
const char *what() const noexcept override { | ||
return content.c_str(); | ||
} | ||
|
||
protected: | ||
std::string content = "Undefined"; | ||
}; | ||
|
||
class UndefinedFunctionException final : public UndefinedException { | ||
public: | ||
explicit UndefinedFunctionException(const std::string &func, const std::vector<std::string> &argVect) noexcept { | ||
content += ": " + func + "("; | ||
|
||
if (!argVect.empty()) { | ||
for (const auto &arg : argVect) { | ||
content += arg + ','; | ||
} | ||
|
||
content.pop_back(); | ||
} | ||
|
||
content += ")"; | ||
} | ||
|
||
const char *what() const noexcept override { | ||
return content.c_str(); | ||
} | ||
}; | ||
|
||
class UndefinedBinaryOperatorException final : public UndefinedException { | ||
public: | ||
explicit UndefinedBinaryOperatorException(const std::string &oper, const std::string &lhs, const std::string &rhs) noexcept { | ||
content += ": (" + lhs + ")" + oper + "(" + rhs + ")"; | ||
} | ||
}; | ||
|
||
class UndefinedUnaryOperatorException final : public UndefinedException { | ||
public: | ||
enum class Type : uint8_t { | ||
Prefix, | ||
Postfix, | ||
}; | ||
|
||
public: | ||
explicit UndefinedUnaryOperatorException(const std::string &oper, const std::string &rhs, const Type type) noexcept { | ||
switch (type) { | ||
case Type::Prefix: | ||
content += ": " + oper + "(" + rhs + ")"; | ||
break; | ||
case Type::Postfix: | ||
content += ": (" + rhs + ")" + oper; | ||
break; | ||
} | ||
} | ||
explicit UndefinedException(std::string inMessage) noexcept : Exception(std::move(inMessage)) {} | ||
}; | ||
|
||
} |
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 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
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
Oops, something went wrong.