Re: Mount volume without error dialog
Re: Mount volume without error dialog
- Subject: Re: Mount volume without error dialog
- From: Gary Lists <email@hidden>
- Date: Mon, 02 Feb 2004 16:37:11 -0500
>
email@hidden wrote [2/2/04 3:24 PM]:
>
>
> When I'm trying to hook up to a server (on OS 10.2.6) this
>
> works fine:
>
>
>
> -------
>
> try
>
> mount volume "afp://" & userName & ":" & passWord & "@" &
>
> serverName & "/" & dirName
>
> on error
>
> -- Error info
>
> end try
>
> -------
>
>
>
> but if the password has become disabled (which happens
>
every
>
> now and then) then I get an error dialog that says
>
> 'Connection Failed. An Appleshare system error occurred'.
>
> The script will not continue until I hit the 'ok' button
>
on
>
> this dialog.
>
>
>
> Is there any way to NOT get this dialog if there is an
>
error
>
> so I can continue with the 'try' block? I'd like to find
>
> another way besides using System Events if possible.
>
>
>
> Thanks.
>
>
>
> Jay
>
>
Hi Jay.
>
>
What you want to do is determine the error number returned,
>
then trap for
>
that specific error (or others) in the try block.
>
>
With these features, you can direct the flow of your script
>
based on the
>
error returned, giving you a finer control over the
>
branching.
>
>
try
>
display dialog "Hello world"
>
on error errMsg number errNum
>
if errNum = -128 then display dialog "you clicked
>
cancel"
>
end try
>
>
>
errMsg and errNum are variables here, so you can call them
>
whatever you
>
wish. They are supplied a value when the error handler is
>
called.
>
--
>
Gary
email@hidden wrote [2/2/04 4:18 PM]:
>
Hi Gary,
>
>
Thanks for your reply. I tried your suggestion as so:
>
>
-------
>
try
>
mount volume "afp://" & userName & ":" & passWord & "@"
>
& serverName & "/" & dirName
>
on error number errNum
>
if errNum is -128 then
>
display dialog "Server Missing"
>
end if
>
end try
>
-------
>
>
But I still get the 'Connection Failed. An Appleshare
>
system error occurred' error dialog before it gets to the
>
'on error' part of the code. I'm curious as to why this
>
dialog still appears even though it's in a try statement.
>
>
Thanks again for your help.
>
>
Jay
>
Jay, you will need to find the actual error number that _your_ error is
associated with.
The -128 that I used is the error returned from the click of the Cancel
button. That same error code will not be what you need.
If you want to see what code is generated, then add the variable 'errNum' to
a debugging dialog, so it will tell you the error number returned.
Something like this inside your 'on error...' handler:
try
...
on error errMsg number errNum
display dialog "This is the error number given: " & errNum
end try
Then, substitute that number for the -128 in my (not so well-stated,
obviously) example.
--
Gary
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.