0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-30 19:41:46 +01:00
posthog/hogql_parser/error.h
Michael Matloka 715a8b924e
fix(hogql): Only expose HogQL exceptions relevant to users (#21329)
* fix(hogql): Only expose HogQL exceptions relevant to users

* Update http.py

* Use exposed exceptions more liberally

* Update more handling

* Update action.py

* Rename `Exception` to `Error`

* Use new hogql-parser version

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
2024-04-05 11:39:20 +00:00

33 lines
1.2 KiB
C++

#pragma once
#include <stdexcept>
#include <string>
#define ERROR_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); \
};
ERROR_CLASS_DEFINITION(HogQLError, std::runtime_error)
// The input does not conform to HogQL syntax.
ERROR_CLASS_DEFINITION(SyntaxError, HogQLError)
// This feature isn't implemented in HogQL (yet).
ERROR_CLASS_DEFINITION(NotImplementedError, HogQLError)
// An internal problem in the parser layer.
ERROR_CLASS_DEFINITION(ParsingError, HogQLError)
// Python runtime errored out somewhere - this means we must use the error it's already raised.
class PyInternalError : public std::exception {
public:
PyInternalError();
};