From dab46ff92de37ae1f294433e87cbae2c468cd3e2 Mon Sep 17 00:00:00 2001 From: rathnapandi Date: Sun, 24 Mar 2024 21:00:15 -0700 Subject: [PATCH] - avoid printing exception for help command --- .../src/main/java/com/axway/apim/lib/CLIOptions.java | 2 +- .../src/main/java/com/axway/apim/lib/error/AppException.java | 2 +- .../src/main/java/com/axway/apim/lib/error/ErrorCode.java | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/apim-adapter/src/main/java/com/axway/apim/lib/CLIOptions.java b/modules/apim-adapter/src/main/java/com/axway/apim/lib/CLIOptions.java index 21cb70aa2..c9457bb82 100644 --- a/modules/apim-adapter/src/main/java/com/axway/apim/lib/CLIOptions.java +++ b/modules/apim-adapter/src/main/java/com/axway/apim/lib/CLIOptions.java @@ -89,7 +89,7 @@ public void parse() throws AppException { this.envProperties = new EnvironmentProperties(cmd.getOptionValue("stage"), getValue("apimCLIHome")); } catch (ParseException e) { printUsage(e.getMessage(), args); - throw new AppException(e.getMessage(), ErrorCode.UNXPECTED_ERROR, e); + throw new AppException(e.getMessage(), ErrorCode.CLI_PARSING, e); } } diff --git a/modules/apim-adapter/src/main/java/com/axway/apim/lib/error/AppException.java b/modules/apim-adapter/src/main/java/com/axway/apim/lib/error/AppException.java index 1991278f1..a48a0e148 100644 --- a/modules/apim-adapter/src/main/java/com/axway/apim/lib/error/AppException.java +++ b/modules/apim-adapter/src/main/java/com/axway/apim/lib/error/AppException.java @@ -47,7 +47,7 @@ public ErrorCode getError() { } public void logException(Logger logger) { - if (error == ErrorCode.SUCCESS) + if (error == ErrorCode.SUCCESS || error == ErrorCode.CLI_PARSING) return; Throwable cause = null; if (error.getPrintStackTrace().booleanValue() || logger.isDebugEnabled()) { diff --git a/modules/apim-adapter/src/main/java/com/axway/apim/lib/error/ErrorCode.java b/modules/apim-adapter/src/main/java/com/axway/apim/lib/error/ErrorCode.java index 3b6eb95e0..af3d8f1ba 100644 --- a/modules/apim-adapter/src/main/java/com/axway/apim/lib/error/ErrorCode.java +++ b/modules/apim-adapter/src/main/java/com/axway/apim/lib/error/ErrorCode.java @@ -6,6 +6,8 @@ public enum ErrorCode { SUCCESS(0, "Replication of the API was successful.", false, LogLevel.INFO), UNSUPPORTED_API_SPECIFICATION(1, "The API-Specification is not supported by the APIM-CLI.", false), + CLI_PARSING(2, "Error in parsing input parameters", false, LogLevel.INFO), + MISSING_PARAMETER(5, "There is a missing parameter.", false), INVALID_PARAMETER(6, "There is an invalid parameter.", false), API_ALREADY_EXISTS(7, "The API already exists for another organization.", false),