From a62885eb85c5c25d949c1718a72e8af81a359ef3 Mon Sep 17 00:00:00 2001 From: TatianaBurek Date: Mon, 16 Oct 2023 14:09:08 -0600 Subject: [PATCH] add error messages to GUI Log output #495 --- java/edu/ucar/metviewer/MVUtil.java | 12 +++++++++--- java/edu/ucar/metviewer/MvResponse.java | 4 ++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/java/edu/ucar/metviewer/MVUtil.java b/java/edu/ucar/metviewer/MVUtil.java index 7640afed..607c1b16 100644 --- a/java/edu/ucar/metviewer/MVUtil.java +++ b/java/edu/ucar/metviewer/MVUtil.java @@ -1872,12 +1872,18 @@ public static MvResponse runRscript( } if (strProcStd.length() > 0) { mvResponse.setInfoMessage( - "==== Start " + type + " output ====\n" + strProcStd + "==== End " + type + " output ===="); + "\n==== Start " + type + " output ====\n" + strProcStd + "==== End " + type + " output ====\n"); } - + // add errors if they exist - only the last line if (strProcErr.length() > 0) { + String[] errorLines = strProcErr.toString().split("\\r?\\n|\\r"); + mvResponse.setInfoMessage( + mvResponse.getInfoMessage() + "\n==== Start " + type + " ERROR ====\n" + errorLines[errorLines.length-1] + "\n==== End " + type + " error ====\n" + + ); + mvResponse.setErrorMessage( - "==== Start " + type + " error ====\n" + strProcErr + "==== End " + type + " error ===="); + "==== Start " + type + " error ====\n" + strProcErr + "==== End " + type + " ERROR ===="); } mvResponse.setSuccess(0 == intExitStatus); return mvResponse; diff --git a/java/edu/ucar/metviewer/MvResponse.java b/java/edu/ucar/metviewer/MvResponse.java index 6c0aaa25..f565f713 100644 --- a/java/edu/ucar/metviewer/MvResponse.java +++ b/java/edu/ucar/metviewer/MvResponse.java @@ -13,8 +13,8 @@ public class MvResponse { private boolean success = false; - private String infoMessage; - private String errorMessage; + private String infoMessage = ""; + private String errorMessage = ""; public boolean isSuccess() { return success;