@@ -52,7 +52,7 @@ public AsyncJob submitRequest(ServerRequest request) throws DataAccessException
5252 if (maxrec > -1 ) { inputs .setParam ("MAXREC" , Integer .toString (maxrec )); }
5353 inputs .setParam ("LANG" , lang ); // in tap 1.0, lang param is required
5454 inputs .setParam ("request" , "doQuery" ); // in tap 1.0, request param is required
55-
55+
5656 AsyncTapJob asyncTap = new AsyncTapJob ();
5757 HttpServices .postData (inputs , (method -> {
5858 String location = HttpServices .getResHeader (method , "Location" , null );
@@ -64,7 +64,7 @@ public AsyncJob submitRequest(ServerRequest request) throws DataAccessException
6464 asyncTap .setErrorMsg ("Failed to submit async job to " + serviceUrl );
6565 }
6666 }));
67-
67+
6868 if (asyncTap .getPhase () == AsyncJob .Phase .PENDING ) {
6969 HttpServices .postData (HttpServiceInput .createWithCredential (asyncTap .baseJobUrl + "/phase" ).setParam ("PHASE" , "RUN" ));
7070 }
@@ -107,7 +107,7 @@ private static String getErrResp(HttpMethod method, String errorUrl) {
107107 } catch (DataAccessException e ) {
108108 errMsg = e .getMessage ();
109109 } catch (Exception e ) {
110- errMsg = "Unable to get error from " + errorUrl ;
110+ errMsg = "Unknown error retrieving error document from " + errorUrl ;
111111 }
112112 return errMsg ;
113113 }
@@ -208,19 +208,21 @@ public String getErrorMsg() {
208208 } else if (HttpServices .isRedirected (method )) {
209209 String location = HttpServices .getResHeader (method , "Location" , null );
210210 if (location != null ) {
211- HttpServices .getData (HttpServiceInput .createWithCredential (location ),
211+ HttpServices .Status redirectStatus = HttpServices . getData (HttpServiceInput .createWithCredential (location ),
212212 (redirectMethod -> err .setSource (getErrResp (redirectMethod , errorUrl ))));
213+ if (redirectStatus .isError ()) {
214+ err .setSource ("Error retrieving redirected error document from " +location +": " +redirectStatus .getErrMsg ());
215+ }
213216 } else {
214- throw new RuntimeException ("Request redirected without a location header" );
217+ throw new RuntimeException ("Error document request redirected without a location header" );
215218 }
219+ } else {
220+ err .setSource ("Error retrieving error document from " +errorUrl +": " +method .getStatusText ());
216221 }
217222 } catch (Exception e ) {
218223 throw new RuntimeException (e .getMessage ());
219224 }
220225 }));
221- if (status .isError ()) {
222- return "Unable to get error from " +errorUrl +" " +status .getErrMsg ();
223- }
224226 return err .getSource ();
225227 }
226228
@@ -248,14 +250,3 @@ private String getFilename(String urlStr) {
248250
249251 }
250252}
251-
252-
253-
254-
255-
256-
257-
258-
259-
260-
261-
0 commit comments