From c3612e9ce03f281750d924a5e16d7154f70625b1 Mon Sep 17 00:00:00 2001 From: Liao Xin <93535922+liewstar@users.noreply.github.com> Date: Thu, 23 Jan 2025 17:42:02 +0800 Subject: [PATCH] feat: show better error message (#42) --- src/main/java/org/casbin/Client.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/casbin/Client.java b/src/main/java/org/casbin/Client.java index a2dadf2..a33b6aa 100644 --- a/src/main/java/org/casbin/Client.java +++ b/src/main/java/org/casbin/Client.java @@ -54,8 +54,13 @@ public static String run(String... args) { return o.toString(); } catch (Exception e) { - e.printStackTrace(); - System.out.println("Run './casbin --help or ./casbin -h' for usage."); + Throwable cause = e.getCause(); + if (cause instanceof org.casbin.jcasbin.exception.CasbinMatcherException) { + System.out.println(cause.getMessage()); + } else { + e.printStackTrace(); + System.out.println("Run './casbin --help or ./casbin -h' for usage."); + } System.exit(1); } return result;