Skip to content

Commit aca0f3d

Browse files
Copilothsluoyz
andcommitted
refactor: improve error messages in DefaultDetector
Co-authored-by: hsluoyz <3787410+hsluoyz@users.noreply.github.com>
1 parent 702f11f commit aca0f3d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/main/java/org/casbin/jcasbin/detector/DefaultDetector.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,12 @@ private Map<String, List<String>> buildGraph(DefaultRoleManager drm) {
7878
List<String> parentRoles = drm.getRoles(roleName);
7979
graph.put(roleName, new ArrayList<>(parentRoles));
8080
}
81-
} catch (NoSuchFieldException | IllegalAccessException e) {
82-
throw new RuntimeException("Failed to access DefaultRoleManager internals", e);
81+
} catch (NoSuchFieldException e) {
82+
throw new RuntimeException("Failed to access 'allRoles' field in DefaultRoleManager via reflection. " +
83+
"The field may have been renamed or removed.", e);
84+
} catch (IllegalAccessException e) {
85+
throw new RuntimeException("Failed to access 'allRoles' field in DefaultRoleManager via reflection. " +
86+
"Permission denied to access the field.", e);
8387
}
8488

8589
return graph;

0 commit comments

Comments
 (0)