File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -71,7 +71,11 @@ class DICOMwebClient {
7171 this . stowURL = this . baseURL ;
7272 }
7373
74+ // Headers to pass to requests.
7475 this . headers = options . headers || { } ;
76+
77+ // Optional error interceptor callback to handle any failed request.
78+ this . errorInterceptor = options . errorInterceptor || function ( ) { } ;
7579 }
7680
7781 static _parseQueryParameters ( params = { } ) {
@@ -86,6 +90,9 @@ class DICOMwebClient {
8690 }
8791
8892 _httpRequest ( url , method , headers , options = { } ) {
93+
94+ const { errorInterceptor} = this ;
95+
8996 return new Promise ( ( resolve , reject ) => {
9097 const request = new XMLHttpRequest ( ) ;
9198 request . open ( method , url , true ) ;
@@ -136,6 +143,8 @@ class DICOMwebClient {
136143 console . error ( error ) ;
137144 console . error ( error . response ) ;
138145
146+ errorInterceptor ( error ) ;
147+
139148 reject ( error ) ;
140149 }
141150 }
You can’t perform that action at this time.
0 commit comments