From 28a309462c24b07e5446d946f1d2b4eb48caf804 Mon Sep 17 00:00:00 2001 From: Damyan Mitev <damyan.mitev@vereign.com> Date: Thu, 30 May 2019 14:16:22 +0300 Subject: [PATCH] add error handling to documentCreateDocument and documentPutDocument --- javascript/src/iframe/viamapi-iframe.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/javascript/src/iframe/viamapi-iframe.js b/javascript/src/iframe/viamapi-iframe.js index f38e8ad..2db81cf 100644 --- a/javascript/src/iframe/viamapi-iframe.js +++ b/javascript/src/iframe/viamapi-iframe.js @@ -1056,6 +1056,10 @@ const connection = Penpal.connectToParent({ const response = await executeRestfulFunction("private", window.viamApi, window.viamApi.documentCreateDocument, config); + if (response.code !== "200") { + return encodeResponse("400", "", response.status); + } + return encodeResponse("200", response.data, "Document created"); }, documentPutDocument: async (passportUUID, resourceid, contentType, file) => { @@ -1080,6 +1084,10 @@ const connection = Penpal.connectToParent({ const response = await executeRestfulFunction( "private", window.viamApi, window.viamApi.documentPutDocument, config, file); + if (response.code !== "200") { + return encodeResponse("400", "", response.status); + } + return encodeResponse("200", response.data, "Document stored"); }, hasSession() { -- GitLab