feat(upload-ova): special handling of invalid params error (#6626)

Fixes #6622

Similar to 036b30212 & 65daa39eb
This commit is contained in:
Julien Fontanet
2023-01-30 14:09:28 +01:00
committed by GitHub
parent bfa0282ecc
commit dc65bb87b5
2 changed files with 16 additions and 1 deletions

View File

@@ -182,7 +182,20 @@ export async function upload(args) {
// FIXME: do not use private properties.
const baseUrl = xo._url.replace(/^ws/, 'http')
const result = await xo.call(method, params)
const result = await xo.call(method, params).catch(error => {
if (!(error != null && error.code === 10 && 'errors' in error.data)) {
throw error
}
const lines = [error.message]
const { errors } = error.data
errors.forEach(error => {
let { instancePath } = error
instancePath = instancePath.length === 0 ? '@' : '@.' + instancePath
lines.push(` property ${instancePath}: ${error.message}`)
})
throw lines.join('\n')
})
let keys, key, url
if (isObject(result) && (keys = getKeys(result)).length === 1) {
key = keys[0]

View File

@@ -27,4 +27,6 @@
<!--packages-start-->
- xo-server-upload-ova patch
<!--packages-end-->