ソースを参照

enhance(asset-sync): add more api exceptions

rcmerci 1 年間 前
コミット
8f7f1fc31d

+ 12 - 0
src/main/frontend/worker/rtc/exception.cljs

@@ -30,6 +30,12 @@ the server will put it to s3 and return its presigned-url to clients.")
 (sr/defkeyword :rtc.exception/different-graph-skeleton
   "remote graph skeleton data is different from local's.")
 
+(sr/defkeyword :rtc.exception/bad-request-body
+  "bad request body, rejected by server-schema")
+
+(sr/defkeyword :rtc.exception/not-allowed
+  "this api-call is not allowed")
+
 (def ex-remote-graph-not-exist
   (ex-info "remote graph not exist" {:type :rtc.exception/remote-graph-not-exist}))
 
@@ -43,6 +49,12 @@ the server will put it to s3 and return its presigned-url to clients.")
 (def ex-local-not-rtc-graph
   (ex-info "RTC is not supported for this local-graph" {:type :rtc.exception/not-rtc-graph}))
 
+(def ex-bad-request-body
+  (ex-info "bad request body" {:type :rtc.exception/bad-request-body}))
+
+(def ex-not-allowed
+  (ex-info "not allowed" {:type :rtc.exception/not-allowed}))
+
 (def ex-unknown-server-error
   (ex-info "Unknown server error" {:type :rtc.exception/unknown-server-error}))
 

+ 3 - 1
src/main/frontend/worker/rtc/ws_util.cljs

@@ -13,7 +13,9 @@
 (defn- handle-remote-ex
   [resp]
   (if-let [e ({:graph-not-exist r.ex/ex-remote-graph-not-exist
-               :graph-not-ready r.ex/ex-remote-graph-not-ready}
+               :graph-not-ready r.ex/ex-remote-graph-not-ready
+               :bad-request-body r.ex/ex-bad-request-body
+               :not-allowed r.ex/ex-not-allowed}
               (:type (:ex-data resp)))]
     (throw e)
     resp))