trim error messages sent to frontend

This commit is contained in:
Nick Krecklow 2020-04-21 18:10:07 -05:00
parent ef2f2bd204
commit 4d66241ada
No known key found for this signature in database
GPG Key ID: 5F149FDE156FFA94

@ -269,17 +269,22 @@ class ServerRegistration {
} }
filterError (err) { filterError (err) {
let message = 'Unknown error'
// Attempt to match to the first possible value // Attempt to match to the first possible value
for (const key of ['message', 'description', 'errno']) { for (const key of ['message', 'description', 'errno']) {
if (err[key]) { if (err[key]) {
return { message = err[key]
message: err[key] break
}
} }
} }
return {
message: 'Unknown error' // Trim the message if too long
if (message.length > 28) {
message = message.substring(0, 28) + '...'
} }
return message
} }
} }