From 7f38eb18acf0db149e89b6f4b3be35c769efdd32 Mon Sep 17 00:00:00 2001
From: Daniel Ziegler <daniel.ziegler@senacor.com>
Date: Wed, 2 Oct 2024 11:48:21 +0200
Subject: [PATCH] Adjust logging of errors thrown by the handler

---
 CHANGELOG.md      | 3 +++
 package-lock.json | 4 ++--
 package.json      | 2 +-
 src/middleware.ts | 2 +-
 4 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 24442b1..53cbc7c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,8 @@
 # CHANGELOG
 
+## 3.0.4 (02.10.2024)
+* Fix logging of errors throw by the handler
+
 ## 3.0.3 (05.09.2024)
 - Remove check for empty result
 
diff --git a/package-lock.json b/package-lock.json
index ab0e53b..bdcdaef 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
 {
     "name": "@senacor/azure-function-middleware",
-    "version": "3.0.3",
+    "version": "3.0.4",
     "lockfileVersion": 3,
     "requires": true,
     "packages": {
         "": {
             "name": "@senacor/azure-function-middleware",
-            "version": "3.0.3",
+            "version": "3.0.4",
             "license": "MIT",
             "dependencies": {
                 "@azure/functions": "^4.0.0",
diff --git a/package.json b/package.json
index 6282fa5..03a6e92 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
     "name": "@senacor/azure-function-middleware",
-    "version": "3.0.3",
+    "version": "3.0.4",
     "description": "Middleware for azure functions to handle authentication, authorization, error handling and logging",
     "main": "dist/index.js",
     "types": "dist/index.d.ts",
diff --git a/src/middleware.ts b/src/middleware.ts
index a2c79db..d863ede 100644
--- a/src/middleware.ts
+++ b/src/middleware.ts
@@ -61,7 +61,7 @@ const middlewareCore =
         }
 
         if (isErrorResult(handlerResult)) {
-            context.error(`An caught error occurred in the execution of the handler: ${stringify(handlerResult)}`);
+            context.error(`An caught error occurred in the execution of the handler:`, handlerResult.$error);
             return handlerResult.$error;
         }