From 4d66241ada126f9a0a0e9c33b626b61f4f743696 Mon Sep 17 00:00:00 2001 From: Nick Krecklow Date: Tue, 21 Apr 2020 18:10:07 -0500 Subject: [PATCH] trim error messages sent to frontend --- lib/servers.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/servers.js b/lib/servers.js index c1e911c..c5665a8 100644 --- a/lib/servers.js +++ b/lib/servers.js @@ -269,17 +269,22 @@ class ServerRegistration { } filterError (err) { + let message = 'Unknown error' + // Attempt to match to the first possible value for (const key of ['message', 'description', 'errno']) { 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 } }