我写了一个 if else 条件,它使用 if not(!) 来抛出错误。但是,条件并没有像我预期的那样运行,并且无论当前用户是谁,都会引发错误:
public void findCorrectUserRole() {
if (Book.name.equals("Test Answers")) {
User currentUser = User.getCurrentUser()
if (currentUser) {
if (!currentUser.hasUserRole("Teacher") || !currentUser.hasUserRole("System Administrator")) {
throw new LCEX("Sorry, only a teacher or System Administrator can edit this.");
}
}
}else{
"Do Something Else"
}
}