cwmiller / broadworks-connector

Simple library for connecting to BroadWorks OCI-P API
MIT License
8 stars 5 forks source link

Catch login errors #34

Closed xciser77 closed 5 years ago

xciser77 commented 5 years ago

I am developing with Laravel and trying to catch login errors.

    $ocip = new OcipClient('tls://broadsoft.link', 'bsusername', 'bspassword');
    try {
        $loginData = $ocip->login();
    } catch (ErrorResponseException $e) {
        $errorMessage = $e->getMessage() . PHP_EOL;
        flash($errorMessage)->error();
        return redirect()->back();
        exit();
    }  

But when I fill in a wrong username or password I get an interl server error 500. When I enable debug. It shows me CWM \ BroadWorksConnector \ Ocip \ LoginException [Error 5401] User is not found on Network Server.

Anyone knows how to catch the login errors with a nice result ?

xciser77 commented 5 years ago

found it out, you should catch the LoginException and not the ErrorResponse Exception $ocip = new OcipClient('tls://broadsoft.link', 'bsusername', 'bspassword'); try { $loginData = $ocip->login(); } catch (LoginException $e) { $errorMessage = $e->getMessage() . PHP_EOL; flash($errorMessage)->error(); return redirect()->back(); exit(); }