0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-28 00:46:45 +01:00
posthog/hogql_parser/error.h
Michael Matloka 8f62e85c9d
chore(hogql): Full error & NULL handling in C++ parser (1.0.0) (#18240)
* chore(hogql): Be defensive against NULLs in the C++ parser

* Clean up on C++ exceptions

* Add to CONTRIBUTING guide

* Revert `AllowShortFunctionsOnASingleLine` change

* Update HogQLX additions too

* Bump version to 1.0.0

* Use new hogql-parser version

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
2023-10-27 13:37:15 +02:00

33 lines
1.3 KiB
C++

#pragma once
#include <stdexcept>
#include <string>
#define EXCEPTION_CLASS_DEFINITION(NAME, BASE) \
class NAME : public BASE { \
public: \
size_t start; \
size_t end; \
explicit NAME(const std::string& message, size_t start, size_t end); \
explicit NAME(const char* message, size_t start, size_t end); \
explicit NAME(const std::string& message); \
explicit NAME(const char* message); \
};
EXCEPTION_CLASS_DEFINITION(HogQLException, std::runtime_error)
// The input does not conform to HogQL syntax.
EXCEPTION_CLASS_DEFINITION(SyntaxException, HogQLException)
// This feature isn't implemented in HogQL (yet).
EXCEPTION_CLASS_DEFINITION(NotImplementedException, HogQLException)
// An internal problem in the parser layer.
EXCEPTION_CLASS_DEFINITION(ParsingException, HogQLException)
// Python runtime errored out somewhere - this means we must use the error it's already raised.
class PyInternalException : public std::exception {
public:
PyInternalException();
};