| 
									
										
										
										
											2020-03-24 14:37:39 +01:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright (c) 2020, Andreas Kling <kling@serenityos.org> | 
					
						
							| 
									
										
										
										
											2021-04-12 00:08:28 +02:00
										 |  |  |  * Copyright (c) 2021, Linus Groh <mail@linusgroh.de> | 
					
						
							| 
									
										
										
										
											2020-03-24 14:37:39 +01:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2021-04-22 01:24:48 -07:00
										 |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							| 
									
										
										
										
											2020-03-24 14:37:39 +01:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-10 12:42:33 +02:00
										 |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-24 14:37:39 +01:00
										 |  |  | #include <AK/FlyString.h>
 | 
					
						
							|  |  |  | #include <LibJS/Runtime/Object.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace JS { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class Error : public Object { | 
					
						
							| 
									
										
										
										
											2020-06-21 15:14:02 +02:00
										 |  |  |     JS_OBJECT(Error, Object); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-24 14:37:39 +01:00
										 |  |  | public: | 
					
						
							| 
									
										
										
										
											2021-04-12 00:08:28 +02:00
										 |  |  |     static Error* create(GlobalObject&, const String& message = {}); | 
					
						
							| 
									
										
										
										
											2020-04-17 19:31:48 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-12 00:08:28 +02:00
										 |  |  |     explicit Error(Object& prototype); | 
					
						
							|  |  |  |     virtual ~Error() override = default; | 
					
						
							| 
									
										
										
										
											2020-03-24 14:37:39 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-10 14:06:52 +02:00
										 |  |  | #define DECLARE_ERROR_SUBCLASS(ClassName, snake_name, PrototypeName, ConstructorName) \
 | 
					
						
							|  |  |  |     class ClassName final : public Error {                                            \ | 
					
						
							| 
									
										
										
										
											2020-06-21 15:14:02 +02:00
										 |  |  |         JS_OBJECT(ClassName, Error);                                                  \ | 
					
						
							|  |  |  |                                                                                       \ | 
					
						
							| 
									
										
										
										
											2020-04-10 14:06:52 +02:00
										 |  |  |     public:                                                                           \ | 
					
						
							| 
									
										
										
										
											2021-04-12 00:08:28 +02:00
										 |  |  |         static ClassName* create(GlobalObject&, const String& message = {});          \ | 
					
						
							| 
									
										
										
										
											2020-04-17 19:31:48 +02:00
										 |  |  |                                                                                       \ | 
					
						
							| 
									
										
										
										
											2021-04-12 00:08:28 +02:00
										 |  |  |         explicit ClassName(Object& prototype);                                        \ | 
					
						
							|  |  |  |         virtual ~ClassName() override = default;                                      \ | 
					
						
							| 
									
										
										
										
											2020-04-10 12:42:33 +02:00
										 |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-01 21:05:25 +01:00
										 |  |  | #define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
 | 
					
						
							| 
									
										
										
										
											2020-04-10 14:06:52 +02:00
										 |  |  |     DECLARE_ERROR_SUBCLASS(ClassName, snake_name, PrototypeName, ConstructorName) | 
					
						
							| 
									
										
										
										
											2020-04-10 12:42:33 +02:00
										 |  |  | JS_ENUMERATE_ERROR_SUBCLASSES | 
					
						
							| 
									
										
										
										
											2020-04-10 14:06:52 +02:00
										 |  |  | #undef __JS_ENUMERATE
 | 
					
						
							| 
									
										
										
										
											2020-03-24 14:37:39 +01:00
										 |  |  | } |