fix: handle validation errors when the response is binary (#3765)
This commit is contained in:
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -144,7 +144,7 @@ window._lnbitsUtils = {
|
||||
return null
|
||||
}
|
||||
},
|
||||
notifyApiError(error) {
|
||||
async notifyApiError(error) {
|
||||
if (!error.response) {
|
||||
return console.error(error)
|
||||
}
|
||||
@@ -154,6 +154,10 @@ window._lnbitsUtils = {
|
||||
500: 'negative'
|
||||
}
|
||||
let messages = error.response.data.detail
|
||||
if (!messages) {
|
||||
const text = await error.response.data?.text()
|
||||
messages = this.parseJSONSafe(text)?.detail
|
||||
}
|
||||
if (messages) {
|
||||
messages = Array.isArray(messages)
|
||||
? messages.map(e => e.msg + ` (${e.loc?.join('/')})`)
|
||||
|
||||
Reference in New Issue
Block a user