| 
									
										
										
										
											2021-09-09 13:51:06 +00:00
										 |  |  | import React from "react"; | 
					
						
							|  |  |  | import { useQuery } from "react-query"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-22 19:52:38 +00:00
										 |  |  | import { HttpError } from "@lib/core/http/error"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-09 13:51:06 +00:00
										 |  |  | const TestAsyncErrorRoute: React.FC = () => { | 
					
						
							|  |  |  |   const { error, isLoading } = useQuery(["error-promise"], async () => { | 
					
						
							|  |  |  |     throw new HttpError({ | 
					
						
							|  |  |  |       statusCode: 400, | 
					
						
							|  |  |  |       message: "A http error occurred on the client side in test-async-error.tsx.", | 
					
						
							|  |  |  |       url: "http://awebsite.that.does.not.exist", | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (isLoading) { | 
					
						
							|  |  |  |     return <>Loading...</>; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (error) { | 
					
						
							|  |  |  |     console.log("An error occurred", error); | 
					
						
							|  |  |  |     throw error; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   return <>If you see this message, there is really something wrong ;)</>; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export default TestAsyncErrorRoute; |