Added error handling
This commit is contained in:
@ -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";
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user