Skip to content

Commit b57bef6

Browse files
authored
feat: optimize exception handling (#43)
1 parent c3612e9 commit b57bef6

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/main/java/org/casbin/Client.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,11 @@ public static String run(String... args) {
5454
return o.toString();
5555

5656
} catch (Exception e) {
57-
Throwable cause = e.getCause();
58-
if (cause instanceof org.casbin.jcasbin.exception.CasbinMatcherException) {
59-
System.out.println(cause.getMessage());
60-
} else {
61-
e.printStackTrace();
62-
System.out.println("Run './casbin --help or ./casbin -h' for usage.");
57+
String errorMessage = e.getMessage();
58+
if (errorMessage == null && e.getCause() != null) {
59+
errorMessage = e.getCause().getMessage();
6360
}
61+
System.out.println(errorMessage);
6462
System.exit(1);
6563
}
6664
return result;

0 commit comments

Comments
 (0)