1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:37:35 +00:00

LibJS: Add all the Error subclasses

This patch adds instance, constructor and prototype classes for:

    - EvalError
    - InternalError
    - RangeError
    - ReferenceError
    - SyntaxError
    - TypeError
    - URIError

Enumerator macros are used to reduce the amount of typing. :^)
This commit is contained in:
Andreas Kling 2020-04-10 12:42:33 +02:00
parent df7b617ba1
commit 58ab76269c
11 changed files with 157 additions and 7 deletions

View file

@ -24,6 +24,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include <AK/FlyString.h>
#include <LibJS/Runtime/Object.h>
@ -45,4 +47,18 @@ private:
String m_message;
};
#define DECLARE_ERROR_SUBCLASS(TitleCase, snake_case) \
class TitleCase final : public Error { \
public: \
TitleCase(const String& message); \
virtual ~TitleCase() override; \
\
private: \
virtual const char* class_name() const override; \
};
#define __JS_ENUMERATE_ERROR_SUBCLASS(TitleCase, snake_case) \
DECLARE_ERROR_SUBCLASS(TitleCase, snake_case)
JS_ENUMERATE_ERROR_SUBCLASSES
#undef __JS_ENUMERATE_ERROR_SUBCLASS
}