From 91e9428f519d4b9f00a99da8c81a28a9c37b4af8 Mon Sep 17 00:00:00 2001 From: Stefan Bocutiu Date: Wed, 4 Dec 2024 22:42:53 +0000 Subject: [PATCH] NullPointerException information lost (#174) The change brings extra logging to identify where the exception occurs. It changes the error log information. Co-authored-by: stheppi Co-authored-by: Andrew Stevenson <10235749+andrewstevenson@users.noreply.github.com> --- .../connect/cloud/common/sink/writer/Writer.scala | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/kafka-connect-cloud-common/src/main/scala/io/lenses/streamreactor/connect/cloud/common/sink/writer/Writer.scala b/kafka-connect-cloud-common/src/main/scala/io/lenses/streamreactor/connect/cloud/common/sink/writer/Writer.scala index 800f904e5..ccf8d33c4 100644 --- a/kafka-connect-cloud-common/src/main/scala/io/lenses/streamreactor/connect/cloud/common/sink/writer/Writer.scala +++ b/kafka-connect-cloud-common/src/main/scala/io/lenses/streamreactor/connect/cloud/common/sink/writer/Writer.scala @@ -59,7 +59,15 @@ class Writer[SM <: FileMetadata]( def innerMessageWrite(writingState: Writing): Either[NonFatalCloudSinkError, Unit] = writingState.formatWriter.write(messageDetail) match { case Left(err: Throwable) => - logger.error(err.getMessage) + logger.error( + s"An error occurred while writing using ${writingState.formatWriter.getClass.getSimpleName}. " + + s"Details: Topic-Partition: ${messageDetail.topic.value}-${messageDetail.partition}, " + + s"Offset: ${messageDetail.offset.value}, " + + s"Key: ${messageDetail.key}, " + + s"Value: ${messageDetail.value}, " + + s"Headers: ${messageDetail.headers}.", + err, + ) NonFatalCloudSinkError(err.getMessage, err.some).asLeft case Right(_) => writeState =