• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Error handling?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Error handling?


  • Subject: Re: Error handling?
  • From: Dave C <email@hidden>
  • Date: Sun, 08 Mar 2015 20:52:51 -0700

Thanks Shane.

I tried your script exactly, and when the volume isn’t busy it works perfectly. But if I start a TM backup before executing the script then it won’t eject and instead after TM is done backing up the icon next to the volume name just keeps turning around (2 arrows in a circle), no end. 

No message is displayed.

What did I do wrong?

Cheers,
Dave

-=-=-=-

Script has evolved to this (see below).

To test error handling I start Time Machine backup and run this script to eject the TM volume “Moe”. The script displays the “Moe ejected. No errors” message. But then immediately following the system displays “Moe could not be ejected because it was in use. Force eject?” message. 

Why did my script not get an error so I could process it? 

-=-=-=-

You have a couple of problems. You really should be trying to eject a disk, not a string. So: 'eject disk "Moe"'. The other problem is that you're ignoring error number 0, and unfortunately that's probably what's being returned when it fails. And finally, the command has no control over the system-level dialog you are seeing -- that's a short-coming you can't do anything about

You're probably better off using the shell command diskutil. So something like this:

set thePosixPath to POSIX path of alias "Moe"
try
do shell script "diskutil eject " & quoted form of thePosixPath
on error errMessage number errorNum
-- do stuff here
end try



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Error handling?
      • From: Shane Stanley <email@hidden>
References: 
 >Error handling? (From: Dave C <email@hidden>)
 >Re: Error handling? (From: "S. J. Cunningham" <email@hidden>)
 >Re: Error handling? (From: Jörgen Stahle <email@hidden>)
 >Re: Error handling? (From: Dave C <email@hidden>)
 >Re: Error handling? (From: Shane Stanley <email@hidden>)

  • Prev by Date: Re: Error handling?
  • Next by Date: Re: Error handling?
  • Previous by thread: Re: Error handling?
  • Next by thread: Re: Error handling?
  • Index(es):
    • Date
    • Thread