@@ -73,11 +73,8 @@ public class DsnCopyExp extends TstZosConnection {
7373 response = dsnCopy. copy(fromDataSetName, toDataSetName, true , false );
7474 } catch (ZosmfRequestException e) {
7575 String errMsg = e. getMessage();
76- if (e. getResponse() != null && e. getResponse(). getResponsePhrase(). isPresent()) {
77- String response = e. getResponse(). getResponsePhrase(). get(). toString();
78- if (! response. isBlank() && ! " {}" . equals(response)) {
79- errMsg = response;
80- }
76+ if (e. getResponse() != null && e. getResponse(). hasTextResponsePhrase()) {
77+ errMsg = e. getResponse(). getResponsePhraseAsString(). orElse(errMsg);
8178 }
8279 throw new RuntimeException (errMsg, e);
8380 }
@@ -112,11 +109,8 @@ public class DsnCopyExp extends TstZosConnection {
112109 response = dsnCopy. copyCommon(dsnCopyInputData);
113110 } catch (ZosmfRequestException e) {
114111 String errMsg = e. getMessage();
115- if (e. getResponse() != null && e. getResponse(). getResponsePhrase(). isPresent()) {
116- String response = e. getResponse(). getResponsePhrase(). get(). toString();
117- if (! response. isBlank() && ! " {}" . equals(response)) {
118- errMsg = response;
119- }
112+ if (e. getResponse() != null && e. getResponse(). hasTextResponsePhrase()) {
113+ errMsg = e. getResponse(). getResponsePhraseAsString(). orElse(errMsg);
120114 }
121115 throw new RuntimeException (errMsg, e);
122116 }
@@ -150,11 +144,8 @@ public class DsnCopyExp extends TstZosConnection {
150144 response = dsnCopy. copyCommon(dsnCopyInputData);
151145 } catch (ZosmfRequestException e) {
152146 String errMsg = e. getMessage();
153- if (e. getResponse() != null && e. getResponse(). getResponsePhrase(). isPresent()) {
154- String response = e. getResponse(). getResponsePhrase(). get(). toString();
155- if (! response. isBlank() && ! " {}" . equals(response)) {
156- errMsg = response;
157- }
147+ if (e. getResponse() != null && e. getResponse(). hasTextResponsePhrase()) {
148+ errMsg = e. getResponse(). getResponsePhraseAsString(). orElse(errMsg);
158149 }
159150 throw new RuntimeException (errMsg, e);
160151 }
@@ -217,11 +208,8 @@ public class DsnCreateExp extends TstZosConnection {
217208 response = dsnCreate. create(dataSetName, sequential());
218209 } catch (ZosmfRequestException e) {
219210 String errMsg = e. getMessage();
220- if (e. getResponse() != null && e. getResponse(). getResponsePhrase(). isPresent()) {
221- String response = e. getResponse(). getResponsePhrase(). get(). toString();
222- if (! response. isBlank() && ! " {}" . equals(response)) {
223- errMsg = response;
224- }
211+ if (e. getResponse() != null && e. getResponse(). hasTextResponsePhrase()) {
212+ errMsg = e. getResponse(). getResponsePhraseAsString(). orElse(errMsg);
225213 }
226214 throw new RuntimeException (errMsg, e);
227215 }
@@ -242,11 +230,8 @@ public class DsnCreateExp extends TstZosConnection {
242230 response = dsnCreate. create(dataSetName, partitioned());
243231 } catch (ZosmfRequestException e) {
244232 String errMsg = e. getMessage();
245- if (e. getResponse() != null && e. getResponse(). getResponsePhrase(). isPresent()) {
246- String response = e. getResponse(). getResponsePhrase(). get(). toString();
247- if (! response. isBlank() && ! " {}" . equals(response)) {
248- errMsg = response;
249- }
233+ if (e. getResponse() != null && e. getResponse(). hasTextResponsePhrase()) {
234+ errMsg = e. getResponse(). getResponsePhraseAsString(). orElse(errMsg);
250235 }
251236 throw new RuntimeException (errMsg, e);
252237 }
@@ -393,11 +378,8 @@ public class DsnGetInfoExp extends TstZosConnection {
393378 return dsnGet. getDsnInfo(dataSetName);
394379 } catch (ZosmfRequestException e) {
395380 String errMsg = e. getMessage();
396- if (e. getResponse() != null && e. getResponse(). getResponsePhrase(). isPresent()) {
397- String response = e. getResponse(). getResponsePhrase(). get(). toString();
398- if (! response. isBlank() && ! " {}" . equals(response)) {
399- errMsg = response;
400- }
381+ if (e. getResponse() != null && e. getResponse(). hasTextResponsePhrase()) {
382+ errMsg = e. getResponse(). getResponsePhraseAsString(). orElse(errMsg);
401383 }
402384 throw new RuntimeException (errMsg, e);
403385 }
@@ -457,11 +439,8 @@ public class DsnDeleteExp extends TstZosConnection {
457439 response = zosDsn. delete(dataSetName);
458440 } catch (ZosmfRequestException e) {
459441 String errMsg = e. getMessage();
460- if (e. getResponse() != null && e. getResponse(). getResponsePhrase(). isPresent()) {
461- String response = e. getResponse(). getResponsePhrase(). get(). toString();
462- if (! response. isBlank() && ! " {}" . equals(response)) {
463- errMsg = response;
464- }
442+ if (e. getResponse() != null && e. getResponse(). hasTextResponsePhrase()) {
443+ errMsg = e. getResponse(). getResponsePhraseAsString(). orElse(errMsg);
465444 }
466445 throw new RuntimeException (errMsg, e);
467446 }
@@ -483,11 +462,8 @@ public class DsnDeleteExp extends TstZosConnection {
483462 response = zosDsn. delete(dataSetName, member);
484463 } catch (ZosmfRequestException e) {
485464 String errMsg = e. getMessage();
486- if (e. getResponse() != null && e. getResponse(). getResponsePhrase(). isPresent()) {
487- String response = e. getResponse(). getResponsePhrase(). get(). toString();
488- if (! response. isBlank() && ! " {}" . equals(response)) {
489- errMsg = response;
490- }
465+ if (e. getResponse() != null && e. getResponse(). hasTextResponsePhrase()) {
466+ errMsg = e. getResponse(). getResponsePhraseAsString(). orElse(errMsg);
491467 }
492468 throw new RuntimeException (errMsg, e);
493469 }
@@ -678,11 +654,8 @@ public class DsnListExp extends TstZosConnection {
678654 datasets = dsnList. getMembers(dataSetName, dsnListInputData);
679655 } catch (ZosmfRequestException e) {
680656 String errMsg = e. getMessage();
681- if (e. getResponse() != null && e. getResponse(). getResponsePhrase(). isPresent()) {
682- String response = e. getResponse(). getResponsePhrase(). get(). toString();
683- if (! response. isBlank() && ! " {}" . equals(response)) {
684- errMsg = response;
685- }
657+ if (e. getResponse() != null && e. getResponse(). hasTextResponsePhrase()) {
658+ errMsg = e. getResponse(). getResponsePhraseAsString(). orElse(errMsg);
686659 }
687660 throw new RuntimeException (errMsg, e);
688661 }
@@ -704,11 +677,8 @@ public class DsnListExp extends TstZosConnection {
704677 datasets = dsnList. getMembers(dataSetName, dsnListInputData);
705678 } catch (ZosmfRequestException e) {
706679 String errMsg = e. getMessage();
707- if (e. getResponse() != null && e. getResponse(). getResponsePhrase(). isPresent()) {
708- String response = e. getResponse(). getResponsePhrase(). get(). toString();
709- if (! response. isBlank() && ! " {}" . equals(response)) {
710- errMsg = response;
711- }
680+ if (e. getResponse() != null && e. getResponse(). hasTextResponsePhrase()) {
681+ errMsg = e. getResponse(). getResponsePhraseAsString(). orElse(errMsg);
712682 }
713683 throw new RuntimeException (errMsg, e);
714684 }
@@ -730,11 +700,8 @@ public class DsnListExp extends TstZosConnection {
730700 datasets = dsnList. getDatasets(dataSetName, dsnListInputData);
731701 } catch (ZosmfRequestException e) {
732702 String errMsg = e. getMessage();
733- if (e. getResponse() != null && e. getResponse(). getResponsePhrase(). isPresent()) {
734- String response = e. getResponse(). getResponsePhrase(). get(). toString();
735- if (! response. isBlank() && ! " {}" . equals(response)) {
736- errMsg = response;
737- }
703+ if (e. getResponse() != null && e. getResponse(). hasTextResponsePhrase()) {
704+ errMsg = e. getResponse(). getResponsePhraseAsString(). orElse(errMsg);
738705 }
739706 throw new RuntimeException (errMsg, e);
740707 }
@@ -756,11 +723,8 @@ public class DsnListExp extends TstZosConnection {
756723 datasets = dsnList. getDatasets(dataSetName, dsnListInputData);
757724 } catch (ZosmfRequestException e) {
758725 String errMsg = e. getMessage();
759- if (e. getResponse() != null && e. getResponse(). getResponsePhrase(). isPresent()) {
760- String response = e. getResponse(). getResponsePhrase(). get(). toString();
761- if (! response. isBlank() && ! " {}" . equals(response)) {
762- errMsg = response;
763- }
726+ if (e. getResponse() != null && e. getResponse(). hasTextResponsePhrase()) {
727+ errMsg = e. getResponse(). getResponsePhraseAsString(). orElse(errMsg);
764728 }
765729 throw new RuntimeException (errMsg, e);
766730 }
@@ -825,15 +789,11 @@ public class DsnWriteExp extends TstZosConnection {
825789 response = dsnWrite. write(dataSetName, member, content);
826790 } catch (ZosmfRequestException e) {
827791 String errMsg = e. getMessage();
828- if (e. getResponse() != null && e. getResponse(). getResponsePhrase(). isPresent()) {
829- String response = e. getResponse(). getResponsePhrase(). get(). toString();
830- if (! response. isBlank() && ! " {}" . equals(response)) {
831- errMsg = response;
832- }
792+ if (e. getResponse() != null && e. getResponse(). hasTextResponsePhrase()) {
793+ errMsg = e. getResponse(). getResponsePhraseAsString(). orElse(errMsg);
833794 }
834795 throw new RuntimeException (errMsg, e);
835796 }
836-
837797 System . out. println(response. toString());
838798 }
839799
@@ -851,15 +811,11 @@ public class DsnWriteExp extends TstZosConnection {
851811 response = dsnWrite. write(dataSetName, content);
852812 } catch (ZosmfRequestException e) {
853813 String errMsg = e. getMessage();
854- if (e. getResponse() != null && e. getResponse(). getResponsePhrase(). isPresent()) {
855- String response = e. getResponse(). getResponsePhrase(). get(). toString();
856- if (! response. isBlank() && ! " {}" . equals(response)) {
857- errMsg = response;
858- }
814+ if (e. getResponse() != null && e. getResponse(). hasTextResponsePhrase()) {
815+ errMsg = e. getResponse(). getResponsePhraseAsString(). orElse(errMsg);
859816 }
860817 throw new RuntimeException (errMsg, e);
861818 }
862-
863819 System . out. println(response. toString());
864820 }
865821
0 commit comments