Skip to content

Commit a77e116

Browse files
authored
[ENHANCEMENT] Log http error code upon unexpected exception calling p… (#2711)
1 parent 444a6be commit a77e116

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/PushSubscriptionSetMethodContract.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2373,7 +2373,7 @@ trait PushSubscriptionSetMethodContract {
23732373
| "notCreated": {
23742374
| "4f29": {
23752375
| "type": "serverFail",
2376-
| "description": "Error when call to Push Server. "
2376+
| "description": "Error when call to Push Server: code 500. "
23772377
| }
23782378
| }
23792379
| },

server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/pushsubscription/WebPushClient.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ object WebPushClientHeader {
6565

6666
sealed abstract class WebPushException(message: String) extends RuntimeException(message)
6767

68-
case class WebPushInvalidRequestException(detailError: String) extends WebPushException(s"Bad request when call to Push Server. ${detailError}")
68+
case class WebPushInvalidRequestException(detailError: String) extends WebPushException(s"Bad request when call to Push Server. $detailError")
6969

70-
case class WebPushTemporarilyUnavailableException(detailError: String) extends WebPushException(s"Error when call to Push Server. ${detailError}")
70+
case class WebPushTemporarilyUnavailableException(httpCode: Int, detailError: String) extends WebPushException(s"Error when call to Push Server: code $httpCode. $detailError")
7171

7272
object DefaultWebPushClient {
7373
val PUSH_SERVER_ERROR_RESPONSE_MAX_LENGTH: Int = 1024
@@ -131,8 +131,8 @@ class DefaultWebPushClient @Inject()(configuration: PushClientConfiguration) ext
131131
case HttpResponseStatus.CREATED => Mono.empty()
132132
case HttpResponseStatus.BAD_REQUEST => preProcessingData(dataBuf)
133133
.flatMap(string => Mono.error(WebPushInvalidRequestException(string)))
134-
case _ => preProcessingData(dataBuf)
135-
.flatMap(string => Mono.error(WebPushTemporarilyUnavailableException(string)))
134+
case statusCode: HttpResponseStatus => preProcessingData(dataBuf)
135+
.flatMap(string => Mono.error(WebPushTemporarilyUnavailableException(statusCode.code, string)))
136136
}.`then`()
137137

138138
private def preProcessingData(dataBuf: ByteBufMono): Mono[String] =

0 commit comments

Comments
 (0)