From ca92bc06172ed4d3d8c6be40fb32f5d0650cabea Mon Sep 17 00:00:00 2001 From: Peter Svensson Date: Mon, 15 Jul 2019 11:34:57 +0200 Subject: [PATCH] additional exception checking in storage-read --- package.json | 2 +- storage/storage-read.js | 30 ++++++++++++++++++------------ 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index ac63af2..ceebd30 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-red-contrib-firebase-admin", - "version": "1.1.4", + "version": "1.1.5", "description": "A node-red module that wraps the server-side admin SDK of firebase, firestore, et.c.", "main": "index.js", "scripts": { diff --git a/storage/storage-read.js b/storage/storage-read.js index 3457111..c4b19f6 100644 --- a/storage/storage-read.js +++ b/storage/storage-read.js @@ -45,19 +45,25 @@ module.exports = function(RED) { })(_file) }) } else { - console.log('reading single file from path '+path) - this.storage - .bucket(bucket) - .file(path).download().then((file)=>{ - console.log('storage-read got file') - //console.dir(file) - msg.payload = file + console.log('* reading single file from path '+path) + try{ + this.storage + .bucket(bucket) + .file(path).download().then((file)=>{ + console.log('storage-read got file') + //console.dir(file) + msg.payload = file + node.send(msg) + }, (fail)=>{ + console.log('storage-read could not find single file '+path) + msg.payload = undefined + node.send(msg) + }) + } catch(ex){ + console.log('storage-read caught exception: '+ex) node.send(msg) - }, (fail)=>{ - console.log('storage-read could not find single file '+path) - msg.payload = undefined - node.send(msg) - }) + } + } } }.bind(this));