Page 1 of 1

[SOLVED] processing External handler exceptions

Posted: Wed Feb 25, 2015 9:58 am
by dbm
I'm using the external ssh.

I've created a function that tries to connect to an ssh server (code below). The login/password are typed by the user in a card and my idea was to validate the login/password to answer if they were correct or not.
If the login/password are correct, the ssh_userauth_password returns "OK" but if intentionaly I type an incorrect user or password i get

execution error at line n/a (External handler: exception) near "Authentication failed"

I was expecting a ssh_userauth_password return similar to a negative answer "no OK" or something like this, but not a external handler exception.

Has Livecode a way to process the external handler exceptions or is it the expected behavior?

Code: Select all

function test_ssh_login sshuser sshpass sshost ssport
  local outVar, ssh_stat, ssh_session
  put ssh_new() into ssh_session
  ssh_options_set ssh_session, "host", sshost
  ssh_options_set ssh_session, "port", ssport
  ssh_connect ssh_session
  put ssh_userauth_password(ssh_session, sshuser, sshpass) into ssh_stat
  ssh_disconnect ssh_session
  ssh_free ssh_session
  return ssh_stat
end test_ssh_login

Re: processing External handler exceptions

Posted: Wed Feb 25, 2015 10:24 am
by Thierry
Hi,

Might be that you are looking for the try control structure?

You can check for it in the dictionary.

Regards,

Thierry

Re: processing External handler exceptions

Posted: Wed Feb 25, 2015 10:50 am
by dbm
Exactly what I need.

The problem learning a new language is that you don't know what to search :D

Thanks for pointing me in the right direction