Merge pull request #2810 from thomasdarimont/issue/KEYCLOAK-2974-handle-ModelException-in-UsersResource
KEYCLOAK-2974: Handle ModelException in UsersResource
This commit is contained in:
commit
b3f3449e39
1 changed files with 7 additions and 0 deletions
|
@ -184,6 +184,8 @@ public class UsersResource {
|
||||||
return ErrorResponse.exists("User exists with same username or email");
|
return ErrorResponse.exists("User exists with same username or email");
|
||||||
} catch (ModelReadOnlyException re) {
|
} catch (ModelReadOnlyException re) {
|
||||||
return ErrorResponse.exists("User is read only!");
|
return ErrorResponse.exists("User is read only!");
|
||||||
|
} catch (ModelException me) {
|
||||||
|
return ErrorResponse.exists("Could not update user!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,6 +228,11 @@ public class UsersResource {
|
||||||
session.getTransaction().setRollbackOnly();
|
session.getTransaction().setRollbackOnly();
|
||||||
}
|
}
|
||||||
return ErrorResponse.exists("User exists with same username or email");
|
return ErrorResponse.exists("User exists with same username or email");
|
||||||
|
} catch (ModelException me){
|
||||||
|
if (session.getTransaction().isActive()) {
|
||||||
|
session.getTransaction().setRollbackOnly();
|
||||||
|
}
|
||||||
|
return ErrorResponse.exists("Could not create user");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue