Add a DOMPromiseDeferred method to handle ExceptionOr<> results
[WebKit-https.git] / Source / WebCore / Modules / cache / CacheStorageConnection.h
index 2bf69e5ac5d22ba2d0a49ba88d540d37f37ea29a..c37e67a8bff98ce7346015af6c47d7f8f8b77a17 100644 (file)
@@ -47,9 +47,16 @@ public:
         NotImplemented,
     };
 
-    WEBCORE_EXPORT static bool queryCacheMatch(const ResourceRequest& request, const ResourceRequest& cachedRequest, const ResourceResponse&, const CacheQueryOptions&);
+    static ExceptionOr<void> errorToException(Error);
+    template<typename T> static ExceptionOr<T> exceptionOrResult(T&& value, Error error)
+    {
+        auto result = errorToException(error);
+        if (result.hasException())
+            return result.releaseException();
+        return std::forward<T>(value);
+    }
 
-    static Exception exceptionFromError(Error);
+    WEBCORE_EXPORT static bool queryCacheMatch(const ResourceRequest& request, const ResourceRequest& cachedRequest, const ResourceResponse&, const CacheQueryOptions&);
 
     struct Record {
         uint64_t identifier;