Keycloak Catch with Exact Problem
TheArKaID opened this issue · 2 comments
Hi, I'm new user of Keycloak, and found this great package, so I use it.
So, I've use this package for some tasks, and only return default error response if there's an error/failed.
Is there any way to get the exact error or failed message, not only the http response but with "humanly" message.
In example, I create second user with already used username, and the Catch error give me this,
What I need is something like Catch error when I directly hit the url (without this package), just like this,
I thought this is only my unknown about this package, thanks for any help and answer
you can get that message with:
try {
adminClient.users.create(user); // or what ever you want to do here
} catch (error) {
console.error(error.response.data.errorMessage); // in your case this will print "User exists with same username"
}
you can get that message with:
try { adminClient.users.create(user); // or what ever you want to do here } catch (error) { console.error(error.response.data.errorMessage); // in your case this will print "User exists with same username" }
Well thanks for the answer, even it's a bit late, coz i was changing all my tasks to hit directly to the Admin API.
But, how can u know that ? I mean, i don't find that in any documentation (or am I miss that ?)