Added error handling

This commit is contained in:
2025-08-29 00:02:45 +02:00
parent f93c463647
commit df4e7777de
17 changed files with 144 additions and 17 deletions

View File

@ -7,6 +7,7 @@
#include "lexer.hpp"
#include "util/text.hpp"
#include "util/error.hpp"
namespace fsh {
@ -67,9 +68,29 @@ namespace fsh {
private:
};
class AstBuildError : public std::runtime_error {
class AstBuildError : public util::LazyError {
public:
AstBuildError(std::string err) : std::runtime_error(err) {}
AstBuildError() {}
};
class AstUnexpectedTypeError : public AstBuildError {
public:
AstUnexpectedTypeError(Lexer::TokenType type) : type(type){};
private:
Lexer::TokenType type;
std::string build_msg() const noexcept override {
return (std::string) "Unexpected " + util::tokens[type];
};
};
class AstNoRedirectError : public AstBuildError {
private:
std::string build_msg() const noexcept override {
return "No redirects provided";
};
};
}