Skip to content

Commit 10f0429

Browse files
committed
Update based on code review.
1 parent 60635dd commit 10f0429

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

apps/sparkpost-samples-app/src/main/java/com/sparkpost/error/samples/ForceTransportError.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
import org.apache.log4j.Logger;
88

99
import com.sparkpost.Client;
10+
import com.sparkpost.exception.SparkPostErrorServerResponseException;
1011
import com.sparkpost.exception.SparkPostException;
11-
import com.sparkpost.exception.SparkPostIllegalServerResponseException;
1212
import com.sparkpost.model.Webhook;
1313
import com.sparkpost.resources.ResourceWebhooks;
1414
import com.sparkpost.sdk.samples.helpers.SparkPostBaseApp;
@@ -46,9 +46,9 @@ private void foceFourHundredError() throws SparkPostException, IOException {
4646
webhook.setName("name with spaces");
4747
try {
4848
ResourceWebhooks.update(restConnection, webhook.getName(), webhook);
49-
throw new IllegalStateException("Error: Expected SparkPostIllegalServerResponseException");
50-
} catch (SparkPostIllegalServerResponseException e) {
51-
System.out.println("GOOD: Sucecssfuly got a SparkPostIllegalServerResponseException");
49+
throw new IllegalStateException("Error: Expected SparkPostErrorServerResponseException");
50+
} catch (SparkPostErrorServerResponseException e) {
51+
System.out.println("GOOD: Sucecssfuly got a SparkPostErrorServerResponseException");
5252

5353
}
5454
}

libs/sparkpost-lib/src/main/java/com/sparkpost/exception/SparkPostErrorServerResponseException.java

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
12
package com.sparkpost.exception;
23

34
import com.yepher.jsondoc.annotations.Description;
5+
46
import lombok.Getter;
57

68
public class SparkPostErrorServerResponseException extends SparkPostException {
@@ -15,4 +17,5 @@ public SparkPostErrorServerResponseException(String message, int responseCode) {
1517
super(message);
1618
this.responseCode = responseCode;
1719
}
20+
1821
}

libs/sparkpost-lib/src/main/java/com/sparkpost/transport/RestConnection.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -315,17 +315,15 @@ private Response receiveErrorResponse(HttpURLConnection conn, Response response)
315315
response.setRequestId(conn.getHeaderField("X-SparkPost-Request-Id"));
316316

317317
if (conn.getContentLength() == 0) {
318-
throw new SparkPostIllegalServerResponseException(
318+
throw new SparkPostErrorServerResponseException(
319319
"Unexpected server response ContentType("
320320
+ conn.getContentType()
321321
+ ") from "
322322
+ conn.getURL()
323-
+ " responseCode("
324-
+ conn.getResponseCode()
325-
+ ")"
326323
+ " contentLength("
327324
+ conn.getContentLength()
328-
+ ")");
325+
+ ")",
326+
conn.getResponseCode());
329327
}
330328
StringBuilder sb = new StringBuilder();
331329

0 commit comments

Comments
 (0)