@@ -64,8 +64,8 @@ protected StripeException(
6464 }
6565
6666 /**
67- * Returns a description of the exception, including the HTTP status code and request ID (if
68- * applicable).
67+ * Returns a developer-facing description of the exception, including the HTTP status code and
68+ * request ID (if applicable).
6969 *
7070 * @return a string representation of the exception.
7171 */
@@ -79,25 +79,22 @@ public String getMessage() {
7979 additionalInfo += "; request-id: " + requestId ;
8080 }
8181 // a separate user message is only available on v2 errors
82- if (stripeErrorApiMode == ApiMode .V2 && this .getUserMessage () != null ) {
83- additionalInfo += "; user-message: " + this .getUserMessage ();
82+ String userMessage = this .getUserMessage ();
83+ if (userMessage != null ) {
84+ additionalInfo += "; user-message: " + userMessage ;
8485 }
8586 return super .getMessage () + additionalInfo ;
8687 }
8788
8889 /**
89- * Returns a description of the user facing exception
90+ * Returns a description of the issue suitable to show an end- user (if available).
9091 *
91- * @return a string representation of the user facing exception.
92+ * @return a string representation of the user facing exception (or null) .
9293 */
9394 public String getUserMessage () {
94- if (this .getStripeError () != null ) {
95- switch (stripeErrorApiMode ) {
96- case V1 :
97- return this .getStripeError ().getMessage ();
98- case V2 :
99- return this .getStripeError ().getUserMessage ();
100- }
95+ // only V2 errors have (optional) user messages
96+ if (this .getStripeError () != null && stripeErrorApiMode == ApiMode .V2 ) {
97+ return this .getStripeError ().getUserMessage ();
10198 }
10299 return null ;
103100 }
0 commit comments