How can I catch the errors of Management API in Laravel SDK?

I’m not sure if this approach is correct, but I’ve found how I can retrieve the error messages.

$user_create_api = Auth0::management()
    ->users()
    ->create(
        connection: 'Username-Password-Authentication',
        body: [ params ]
    );

$message = json_decode($user_create_api->getBody()->getContents())->message

This seems to be working well so far.

2 Likes