From 1c8c99c20b4fa26676ed5618d61679e7c3f1037c Mon Sep 17 00:00:00 2001 From: Muskan Sethi Date: Thu, 27 Jun 2024 09:47:59 +0530 Subject: [PATCH 1/3] better error handling --- lib/aws-s3.js | 3 +++ lib/malwareScanner.js | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/aws-s3.js b/lib/aws-s3.js index ae140568..6ea6fa50 100644 --- a/lib/aws-s3.js +++ b/lib/aws-s3.js @@ -7,6 +7,9 @@ const { SELECT } = cds.ql; module.exports = class AWSAttachmentsService extends require("./basic") { init() { const creds = this.options.credentials; + + if(!creds) throw new Error("SAP Object Store instance is not binded."); + this.bucket = creds.bucket; this.client = new S3Client({ region: creds.region, diff --git a/lib/malwareScanner.js b/lib/malwareScanner.js index 17cbc8e5..c1c7ba70 100644 --- a/lib/malwareScanner.js +++ b/lib/malwareScanner.js @@ -92,7 +92,11 @@ async function entryExists(Attachments, key) { function getCredentials() { - return xsenv.serviceCredentials({ label: "malware-scanner" }); + try { + return xsenv.serviceCredentials({ label: "malware-scanner" }); + } catch (error) { + throw new Error("SAP Malware Scanning service is not binded."); + } } function streamToString(stream) { From 3aca5d9156e41cb67656897da5dcbc94a28ce824 Mon Sep 17 00:00:00 2001 From: Muskan Sethi Date: Thu, 27 Jun 2024 09:51:32 +0530 Subject: [PATCH 2/3] updated changelog --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3bcb5403..3aea491d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). The format is based on [Keep a Changelog](http://keepachangelog.com/). +## Version 1.1.3 + +### Changed + +- Improved error handling + + ## Version 1.1.2 ### Added From c85e7a66fe2e7d9f57c12ce9f9b857a37bf2fab6 Mon Sep 17 00:00:00 2001 From: Muskan Sethi Date: Thu, 27 Jun 2024 13:24:28 +0530 Subject: [PATCH 3/3] minor change --- lib/aws-s3.js | 2 +- lib/malwareScanner.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/aws-s3.js b/lib/aws-s3.js index 6ea6fa50..ee56f8ea 100644 --- a/lib/aws-s3.js +++ b/lib/aws-s3.js @@ -8,7 +8,7 @@ module.exports = class AWSAttachmentsService extends require("./basic") { init() { const creds = this.options.credentials; - if(!creds) throw new Error("SAP Object Store instance is not binded."); + if(!creds) throw new Error("SAP Object Store instance is not bound."); this.bucket = creds.bucket; this.client = new S3Client({ diff --git a/lib/malwareScanner.js b/lib/malwareScanner.js index c1c7ba70..f250a68d 100644 --- a/lib/malwareScanner.js +++ b/lib/malwareScanner.js @@ -95,7 +95,7 @@ function getCredentials() { try { return xsenv.serviceCredentials({ label: "malware-scanner" }); } catch (error) { - throw new Error("SAP Malware Scanning service is not binded."); + throw new Error("SAP Malware Scanning service is not bound."); } }