File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -98,11 +98,21 @@ export default class WebServiceClient {
9898 } ;
9999
100100 let data ;
101+ /*
102+ We handle two kinds of errors here:
103+ 1. Network errors, such as timeouts or CORS errors. These will be caught
104+ by the catch block and rethrown as a WebServiceClientError.
105+ 2. Errors returned by the MaxMind web service, namely non-200 status codes. These
106+ will be caught by the handleBadServerResponse method and rethrown/rejected as a
107+ WebServiceClientError.
108+ */
101109 try {
102110 const response = await fetch ( url , options ) ;
103111
104112 if ( ! response . ok ) {
105- return Promise . reject ( await this . handleError ( response , url ) ) ;
113+ return Promise . reject (
114+ await this . handleBadServerResponse ( response , url )
115+ ) ;
106116 }
107117
108118 if ( response . status === 204 ) {
@@ -136,7 +146,7 @@ export default class WebServiceClient {
136146 return new modelClass ( data ) ;
137147 }
138148
139- private async handleError (
149+ private async handleBadServerResponse (
140150 response : Response ,
141151 url : string
142152 ) : Promise < WebServiceClientError > {
You can’t perform that action at this time.
0 commit comments