From a3379dcdf57f3d85846188945cacf865cdc63552 Mon Sep 17 00:00:00 2001 From: Patrick Dowler Date: Tue, 10 Mar 2026 14:00:18 -0700 Subject: [PATCH 1/2] cadc-rest: improve error message logging --- cadc-rest/build.gradle | 2 +- .../src/main/java/ca/nrc/cadc/rest/RestAction.java | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/cadc-rest/build.gradle b/cadc-rest/build.gradle index 41cb7040..9e75d6d5 100644 --- a/cadc-rest/build.gradle +++ b/cadc-rest/build.gradle @@ -15,7 +15,7 @@ sourceCompatibility = 11 group = 'org.opencadc' -version = '1.4.9' +version = '1.4.10' description = 'OpenCADC REST server library' def git_url = 'https://github.com/opencadc/core' diff --git a/cadc-rest/src/main/java/ca/nrc/cadc/rest/RestAction.java b/cadc-rest/src/main/java/ca/nrc/cadc/rest/RestAction.java index 62b864a5..284dfea3 100644 --- a/cadc-rest/src/main/java/ca/nrc/cadc/rest/RestAction.java +++ b/cadc-rest/src/main/java/ca/nrc/cadc/rest/RestAction.java @@ -395,27 +395,35 @@ public Object run() handleException(ex, 403, "permission denied -- reason: invalid proxy certficate", false, true); } catch (IllegalArgumentException | UnsupportedOperationException | InlineContentException ex) { logInfo.setSuccess(true); + logInfo.setMessage(ex.getMessage()); handleException(ex, 400, ex.getMessage(), false, false); } catch (ResourceNotFoundException ex) { logInfo.setSuccess(true); + logInfo.setMessage(ex.getMessage()); handleException(ex, 404, ex.getMessage(), false, false); } catch (ResourceAlreadyExistsException ex) { logInfo.setSuccess(true); + logInfo.setMessage(ex.getMessage()); handleException(ex, 409, ex.getMessage(), false, false); } catch (PreconditionFailedException ex) { logInfo.setSuccess(true); handleException(ex, 412, ex.getMessage(), false, false); } catch (ByteLimitExceededException ex) { logInfo.setSuccess(true); - handleException(ex, 413, ex.getMessage(), false, false); + String msg = "limit: " + ex.getLimit(); + logInfo.setMessage("limit: " + msg); + handleException(ex, 413, msg, false, false); } catch (RangeNotSatisfiableException ex) { logInfo.setSuccess(true); + logInfo.setMessage(ex.getMessage()); handleException(ex, 416, ex.getMessage(), false, false); } catch (ExpectationFailedException ex) { logInfo.setSuccess(true); + logInfo.setMessage(ex.getMessage()); handleException(ex, 417, ex.getMessage(), false, false); } catch (TransientException ex) { logInfo.setSuccess(true); + logInfo.setMessage(ex.getMessage()); syncOutput.setHeader(HttpTransfer.SERVICE_RETRY, ex.getRetryDelay()); if (!readable || !writable) { // exception due to service state: keep logs tidy From 8804769b336f8ad8eb78cf26f1125d93fc1306f8 Mon Sep 17 00:00:00 2001 From: Patrick Dowler Date: Thu, 12 Mar 2026 16:42:51 -0700 Subject: [PATCH 2/2] cadc-util: expose ConfigFileReader file-finding method --- cadc-util/build.gradle | 2 +- .../ca/nrc/cadc/util/ConfigFileReader.java | 22 +++++++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/cadc-util/build.gradle b/cadc-util/build.gradle index 779cfaed..0a9f8c87 100644 --- a/cadc-util/build.gradle +++ b/cadc-util/build.gradle @@ -15,7 +15,7 @@ sourceCompatibility = 1.8 group = 'org.opencadc' -version = '1.12.14' +version = '1.12.15' description = 'OpenCADC core utility library' def git_url = 'https://github.com/opencadc/core' diff --git a/cadc-util/src/main/java/ca/nrc/cadc/util/ConfigFileReader.java b/cadc-util/src/main/java/ca/nrc/cadc/util/ConfigFileReader.java index a11ba247..084dc853 100644 --- a/cadc-util/src/main/java/ca/nrc/cadc/util/ConfigFileReader.java +++ b/cadc-util/src/main/java/ca/nrc/cadc/util/ConfigFileReader.java @@ -91,14 +91,7 @@ public class ConfigFileReader { private final File configFile; private String commentChars = "#"; - /** - * Normal constructor to find the specified config file. This method checks for a - * custom location (ca.nrc.cadc.util.ConfigFileReader.dir system property) and - * defaults to {user.home}/config. - * - * @param filename relative filename for the configuration - */ - public ConfigFileReader(String filename) { + public static File findConfigFile(String filename) { if (filename == null) { throw new IllegalArgumentException("filename cannot be null."); } @@ -108,7 +101,18 @@ public ConfigFileReader(String filename) { configDir = System.getProperty(CONFIG_DIR_SYSTEM_PROPERTY); } - this.configFile = new File(new File(configDir), filename); + return new File(new File(configDir), filename); + } + + /** + * Normal constructor to find the specified config file. This method checks for a + * custom location (ca.nrc.cadc.util.ConfigFileReader.dir system property) and + * defaults to {user.home}/config. + * + * @param filename relative filename for the configuration + */ + public ConfigFileReader(String filename) { + this.configFile = findConfigFile(filename); } public ConfigFileReader(File configFile) {