diff --git a/lib/debug.js b/lib/debug.js index 306ee2bf..7f16654e 100644 --- a/lib/debug.js +++ b/lib/debug.js @@ -15,3 +15,4 @@ exports.accounts = debug('solid:accounts') exports.email = debug('solid:email') exports.ldp = debug('solid:ldp') exports.fs = debug('solid:fs') +exports.prep = debug('solid:prep') diff --git a/lib/handlers/notify.js b/lib/handlers/notify.js index 6adedf97..fe758da1 100644 --- a/lib/handlers/notify.js +++ b/lib/handlers/notify.js @@ -4,6 +4,7 @@ const libPath = require('path/posix') const headerTemplate = require('express-prep/templates').header const solidRDFTemplate = require('../rdf-notification-template') +const debug = require('../debug').prep const ALLOWED_RDF_MIME_TYPES = [ 'application/ld+json', @@ -82,7 +83,11 @@ function handler (req, res, next) { } }) } catch (error) { - // Failed notification message + debug(`Failed to trigger notification on route ${fullUrl}`) + // No special handling is necessary since the resource mutation was + // already successful. The purpose of this block is to prevent Express + // from triggering error handling middleware when notifications fail. + // An error notification might be sent in the future. } } @@ -90,9 +95,9 @@ function handler (req, res, next) { // POST in Solid creates a child resource const parent = getParent(path) if (parent && method !== 'POST') { + const parentID = res.setEventID(parent) + const parentUrl = new URL(parent, fullUrl) try { - const parentID = res.setEventID(parent) - const parentUrl = new URL(parent, fullUrl) trigger({ path: parent, generateNotification ( @@ -115,7 +120,11 @@ function handler (req, res, next) { } }) } catch (error) { - // Failed notification message + debug(`Failed to trigger notification on parent route ${parentUrl}`) + // No special handling is necessary since the resource mutation was + // already successful. The purpose of this block is to prevent Express + // from triggering error handling middleware when notifications fail. + // An error notification might be sent in the future. } }