From 447be3552c69c3aaf75b004b488bbe9d8012c39c Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Sat, 8 Apr 2023 21:04:40 -0600 Subject: [PATCH] Better error handling --- core/servers/content/gopher.js | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/core/servers/content/gopher.js b/core/servers/content/gopher.js index 01642721..c8cfb021 100644 --- a/core/servers/content/gopher.js +++ b/core/servers/content/gopher.js @@ -557,17 +557,24 @@ exports.getModule = class GopherModule extends ServerModule { this.makeItem(ItemTypes.InfoMessage, `Messages in ${area.name}`), this.makeItem(ItemTypes.InfoMessage, '(newest first)'), this.makeItem(ItemTypes.InfoMessage, '-'.repeat(70)), - ...msgList.map(msg => - this.makeItem( + ...msgList.map(msg => { + let m; + try { + m = moment(msg.modTimestamp); + } catch (e) { + this.log.warn( + `Error parsing "${msg.modTimestamp}"; expected timestamp: ${e.message}` + ); + m = moment(); + } + return this.makeItem( ItemTypes.TextFile, - `${moment(msg.modTimestamp).format( - 'YYYY-MM-DD hh:mma' - )}: ${this.shortenSubject(msg.subject)} (${ - msg.fromUserName - } to ${msg.toUserName})`, + `${m.format('YYYY-MM-DD hh:mma')}: ${this.shortenSubject( + msg.subject + )} (${msg.fromUserName} to ${msg.toUserName})`, `/msgarea/${confTag}/${areaTag}/${msg.messageUuid}` - ) - ), + ); + }), ].join(''); this.log.debug({ confTag, areaTag }, 'Gopher serving message list');