Merge pull request #3488 from penpot/niwinz-staging-bugfixes-5

 Add better error reporting on response encoding middleware
This commit is contained in:
Alejandro 2023-08-03 16:46:05 +02:00 committed by GitHub
commit f3bf04e1c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 9 deletions

View File

@ -21,8 +21,8 @@
java-http-clj/java-http-clj {:mvn/version "0.4.3"} java-http-clj/java-http-clj {:mvn/version "0.4.3"}
funcool/yetti funcool/yetti
{:git/tag "v9.15" {:git/tag "v9.16"
:git/sha "aa9b967" :git/sha "7df3e08"
:git/url "https://github.com/funcool/yetti.git" :git/url "https://github.com/funcool/yetti.git"
:exclusions [org.slf4j/slf4j-api]} :exclusions [org.slf4j/slf4j-api]}

View File

@ -71,7 +71,7 @@ penpot - error report v2 {{id}}
{% if value %} {% if value %}
<div class="table-row multiline"> <div class="table-row multiline">
<div id="value" class="table-key">VALIDATION VALUE: </div> <div id="value" class="table-key">VALUE: </div>
<div class="table-val"> <div class="table-val">
<pre>{{value}}</pre> <pre>{{value}}</pre>
</div> </div>

View File

@ -22,9 +22,10 @@
(:import (:import
com.fasterxml.jackson.core.JsonParseException com.fasterxml.jackson.core.JsonParseException
com.fasterxml.jackson.core.io.JsonEOFException com.fasterxml.jackson.core.io.JsonEOFException
com.fasterxml.jackson.databind.exc.MismatchedInputException
io.undertow.server.RequestTooBigException io.undertow.server.RequestTooBigException
java.io.OutputStream java.io.InputStream
java.io.InputStream)) java.io.OutputStream))
(set! *warn-on-reflection* true) (set! *warn-on-reflection* true)
@ -78,11 +79,13 @@
(or (instance? JsonEOFException cause) (or (instance? JsonEOFException cause)
(instance? JsonParseException cause)) (instance? JsonParseException cause)
(instance? MismatchedInputException cause))
(raise (ex/error :type :validation (raise (ex/error :type :validation
:code :malformed-json :code :malformed-json
:hint (ex-message cause) :hint (ex-message cause)
:cause cause)) :cause cause))
:else :else
(raise cause)))] (raise cause)))]
@ -118,7 +121,9 @@
(t/write! tw data))) (t/write! tw data)))
(catch java.io.IOException _) (catch java.io.IOException _)
(catch Throwable cause (catch Throwable cause
(l/error :hint "unexpected error on encoding response" :cause cause)) (binding [l/*context* {:value data}]
(l/error :hint "unexpected error on encoding response"
:cause cause)))
(finally (finally
(.close ^OutputStream output-stream)))))) (.close ^OutputStream output-stream))))))
@ -131,8 +136,9 @@
(catch java.io.IOException _) (catch java.io.IOException _)
(catch Throwable cause (catch Throwable cause
(l/error :hint "unexpected error on encoding response" (binding [l/*context* {:value data}]
:cause cause)) (l/error :hint "unexpected error on encoding response"
:cause cause)))
(finally (finally
(.close ^OutputStream output-stream)))))) (.close ^OutputStream output-stream))))))

View File

@ -58,6 +58,9 @@
(when-let [params (:request/params context)] (when-let [params (:request/params context)]
{:params (pp/pprint-str params :width 200)}) {:params (pp/pprint-str params :width 200)})
(when-let [value (:value context)]
{:value (pp/pprint-str value :width 200 :length 50 :level 10)})
(when-let [data (some-> data (dissoc ::s/problems ::s/value ::s/spec ::sm/explain :hint))] (when-let [data (some-> data (dissoc ::s/problems ::s/value ::s/spec ::sm/explain :hint))]
{:data (pp/pprint-str data :width 200)}) {:data (pp/pprint-str data :width 200)})