@@ -64,8 +64,8 @@ protected StripeException(
64
64
}
65
65
66
66
/**
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).
69
69
*
70
70
* @return a string representation of the exception.
71
71
*/
@@ -79,25 +79,22 @@ public String getMessage() {
79
79
additionalInfo += "; request-id: " + requestId ;
80
80
}
81
81
// 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 ;
84
85
}
85
86
return super .getMessage () + additionalInfo ;
86
87
}
87
88
88
89
/**
89
- * Returns a description of the user facing exception
90
+ * Returns a description of the issue suitable to show an end- user (if available).
90
91
*
91
- * @return a string representation of the user facing exception.
92
+ * @return a string representation of the user facing exception (or null) .
92
93
*/
93
94
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 ();
101
98
}
102
99
return null ;
103
100
}
0 commit comments