| 
									
										
										
										
											2022-02-07 15:12:41 +01:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright (c) 2022, David Tuin <davidot@serenityos.org> | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <LibJS/Forward.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace Web::HTML { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-27 19:53:22 +01:00
										 |  |  | enum class ErrorInPromise { | 
					
						
							|  |  |  |     No, | 
					
						
							|  |  |  |     Yes, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-08 19:38:32 +04:00
										 |  |  | void report_exception_to_console(JS::Value, JS::Realm&, ErrorInPromise); | 
					
						
							|  |  |  | void report_exception(JS::Completion const&, JS::Realm&); | 
					
						
							| 
									
										
										
										
											2022-02-08 15:37:36 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | template<typename T> | 
					
						
							| 
									
										
										
										
											2022-10-08 19:38:32 +04:00
										 |  |  | inline void report_exception(JS::ThrowCompletionOr<T> const& result, JS::Realm& realm) | 
					
						
							| 
									
										
										
										
											2022-02-08 15:37:36 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     VERIFY(result.is_throw_completion()); | 
					
						
							| 
									
										
										
										
											2022-10-08 19:38:32 +04:00
										 |  |  |     report_exception(result.throw_completion(), realm); | 
					
						
							| 
									
										
										
										
											2022-02-08 15:37:36 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2022-02-07 15:12:41 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | } |