Friday, August 17, 2018

#1 2009-08-16 01:22:02 pm

regulus6633
Member
From:: Taulov, Denmark
Registered: 2006-11-02
Posts: 1695
Website

Mac Error Codes

The following will help you find what error codes mean. When run you enter an error number (include the minus sign if appropriate) and the script returns the explanation for that number if it was found. Note that starting up the script takes a little time because when launched the script searches you computer... so be patient initially.

Did you know that there were files on your computer that contain explanations about the error codes? I didn't until I read the following. It explains all about error codes, error domains, and those files. The script reads those files and pulls out the information.
http://developer.apple.com/documentatio … dling.html

I've found that some error codes are listed in several of the files so some times you get several results back when you search... you'll have to figure out which of the explanations is really the one meant for you. Often looking at the error domain will give you a clue.

Parsing and extracting the information from these files was difficult to say the least because many of them are formatted differently... so any improvements to the code are welcome.

Applescript:

you can find the latest script in post #9

Last edited by regulus6633 (2010-09-01 11:27:54 am)

Offline

 

#2 2009-08-16 03:45:53 pm

Adam Bell
Administrator
From:: Nova Scotia, Canada
Registered: 2005-10-04
Posts: 4663

Re: Mac Error Codes

Doesn't always agree with this list that I dredged up several years ago (2005), but usually close:

Error Numbers and Error Messages A
See the following sections for error numbers and error messages for the
specified types of errors:
n “Operating System Errors” (page 384)
n “Apple Event Errors” (page 385)
n “Application Scripting Errors” (page 387)
n “AppleScript Errors” (page 388)
Operating System Errors A
An operating system error is an error that occurs when AppleScript or an
application requests services from the Mac OS. They are rare, and more
important, there’s usually nothing you can do about them in a script. A few,
such as "File <name> wasn't found" and "Application isn't running", make
sense for scripts to handle.
Error
number Error message
0 No error.
–34 Disk <name> is full.
–35 Disk <name> wasn't found.
–37 Bad name for file.
–38 File <name> wasn't open.
–39 End of file error.
–42 Too many files open.
–43 File <name> wasn't found.
–44 Disk <name> is write protected.
–45 File <name> is locked.
–46 Disk <name> is locked.
–47 File <name> is busy.
A P P E N D I X A
The Language at a Glance
Error Numbers and Error Messages 385
5/5/99 ã Apple Computer, Inc.
Apple Event Errors A
An Apple event error is an error that occurs when Apple events sent by
AppleScript fail. Many of these errors, such as "No user interaction allowed",
–48 Duplicate file name.
–49 File <name> is already open.
–50 Parameter error.
–51 File reference number error.
–61 File not open with write permission.
–108 Out of memory.
–120 Folder <name> wasn’t found.
–124 Disk <name> is disconnected.
–128 User canceled.
–192 A resource wasn’t found.
–600 Application isn't running.
–601 Not enough room to launch application with special requirements.
–602 Application is not 32-bit clean.
–605 More memory is needed than is specified in the size resource.
–606 Application is background-only.
–607 Buffer is too small.
–608 No outstanding high-level event.
–609 Connection is invalid.
–904 Not enough system memory to connect to remote application.
–905 Remote access is not allowed.
–906 <name> isn't running or program linking isn't enabled.
–915 Can't find remote machine.
–30720 Invalid date and time <date string>.
Error
number Error message
A P P E N D I X A
The Language at a Glance
386 Error Numbers and Error Messages
5/5/99 ã Apple Computer, Inc.
are of interest to users. Also of interest to users are errors that have to do with
reference forms, as well as errors such as "No such object".
Error
number Error message
–1700 Can’t make some data into the expected type.
–1701 Some parameter is missing for <commandName>.
–1702 Some data could not be read.
–1703 Some data was the wrong type.
–1704 Some parameter was invalid.
–1705 Operation involving a list item failed.
–1706 Need a newer version of the Apple Event Manager.
–1707 Event isn’t an Apple event.
–1708 <reference> doesn’t understand the <commandName> message.
–1709 AEResetTimer was passed an invalid reply.
–1710 Invalid sending mode was passed.
–1711 User canceled out of wait loop for reply or receipt.
–1712 Apple event timed out.
–1713 No user interaction allowed.
–1714 Wrong keyword for a special function.
–1715 Some parameter wasn’t understood.
–1716 Unknown Apple event address type.
–1717 The handler <identifier> is not defined.
–1718 Reply has not yet arrived.
–1719 Can’t get <reference>. Invalid index.
–1720 Invalid range.
–1721 <expression> doesn’t match the parameters <parameterNames> for
<commandName>.
–1723 Can’t get <expression>. Access not allowed.
–1725 Illegal logical operator called.
–1726 Illegal comparison or logical.
–1727 Expected a reference.
A P P E N D I X A
The Language at a Glance
Error Numbers and Error Messages 387
5/5/99 ã Apple Computer, Inc.
Application Scripting Errors A
An application scripting error is an error returned by an application when
handling standard AppleScript commands (commands that apply to all
applications). Many of these errors, such as "The specified object is a
property, not an element", are of interest to users and should be handled.
Developers can define new application errors in the -10,000 range for their
applications.
–1728 Can’t get <reference>.
–1729 Object counting procedure returned a negative count.
–1730 Container specified was an empty list.
–1731 Unknown object type.
–1750 Scripting component error.
–1751 Invalid script id.
–1752 Script doesn’t seem to belong to AppleScript.
–1753 Script error.
–1754 Invalid selector given.
–1755 Invalid access.
–1756 Source not available.
–1757 No such dialect.
–1758 Data couldn’t be read because its format is obsolete.
–1759 Data couldn’t be read because its format is too new.
–1760 Recording is already on.
Error
number Error message
–10000 Apple event handler failed.
–10001 A descriptor type mismatch occurred.
Error
number Error message
A P P E N D I X A
The Language at a Glance
388 Error Numbers and Error Messages
5/5/99 ã Apple Computer, Inc.
AppleScript Errors A
An AppleScript error is an error that occurs when AppleScript processes script
statements. Nearly all of these are of interest to users. For errors returned by an
application, see the documentation for that application.
–10002 Invalid key form.
–10003 Can't set <object or data> to <object or data>. Access not allowed.
–10004 A privilege violation occurred.
–10005 The read operation wasn't allowed.
–10006 Can't set <object or data> to <object or data>.
–10007 The index of the event is too large to be valid.
–10008 The specified object is a property, not an element.
–10009 Can’t supply the requested descriptor type for the data.
–10010 The Apple event handler can’t handle objects of this class.
–10011 Couldn’t handle this command because it wasn’t part of the current transaction.
–10012 The transaction to which this command belonged isn’t a valid transaction.
–10013 There is no user selection.
–10014 Handler only handles single objects.
–10015 Can’t undo the previous Apple event or user action.
Error
number Error message
-2700 Unknown error.
–2701 Can’t divide <number> by zero.
–2702 The result of a numeric operation was too large.
–2703 <reference> can’t be launched because it is not an application.
–2704 <reference> isn’t scriptable.
–2705 The application has a corrupted dictionary.
–2706 Stack overflow.
–2707 Internal table overflow.
A P P E N D I X A
The Language at a Glance
Error Numbers and Error Messages 389
5/5/99 ã Apple Computer, Inc.
–2708 Attempt to create a value larger than the allowable size.
–2709 Can’t get the event dictionary.
–2720 Can’t both consider and ignore <attribute>.
–2721 Can’t perform operation on text longer than 32K bytes.
–2729 Message size too large for the 7.0 Finder.
–2740 A <language element> can’t go after this <language element>.
–2741 Expected <language element> but found <language element>.
–2750 The <name> parameter is specified more than once.
–2751 The <name> property is specified more than once.
–2752 The <name> handler is specified more than once.
–2753 The variable <name> is not defined.
–2754 Can’t declare <name> as both a local and global variable.
–2755 Exit statement was not in a repeat loop.
–2760 Tell statements are nested too deeply.
–2761 <name> is illegal as a formal parameter.
–2762 <name> is not a parameter name for the event <event>.
–2763 No result was returned for some argument of this expression.


iMac running OS X 10.13.1

Offline

 

#3 2009-08-16 04:43:45 pm

regulus6633
Member
From:: Taulov, Denmark
Registered: 2006-11-02
Posts: 1695
Website

Re: Mac Error Codes

Adam Bell wrote:

Doesn't always agree with this list that I dredged up several years ago (2005), but usually close:


I'm not sure what you're saying. I'm pulling the information directly from the files found in /System/Library/Frameworks (and a few others). There's no doubt that the files I'm using have the most correct and most up-to-date information. That's what the Error Handling article I linked to talks about... that's the actual source for the error codes and their description. The way I'm doing this should remain accurate over time as Apple makes changes to these files.

There can only be 2 errors with the way I'm doing this, 1) I'm not finding every error file or 2) I'm not parsing the error information properly. If you find a glaring mismatch then please look at the file where I found the information (I list the file in the results) and double check if I parsed the file correctly. Hopefully we can work out the best solution for parsing those files.

Last edited by regulus6633 (2009-08-16 04:47:29 pm)

Offline

 

#4 2009-08-16 04:48:44 pm

Adam Bell
Administrator
From:: Nova Scotia, Canada
Registered: 2005-10-04
Posts: 4663

Re: Mac Error Codes

Didn’t mean to criticize at all, Hank -- I'm amazed that a 4-year old list is still reasonably accurate compared to your script, not the opposite. I posted it to give folks some numbers to play with.


iMac running OS X 10.13.1

Offline

 

#5 2009-08-16 04:52:07 pm

regulus6633
Member
From:: Taulov, Denmark
Registered: 2006-11-02
Posts: 1695
Website

Re: Mac Error Codes

Good idea then Adam. That makes sense. I posted this just for the process of people being able to check my code so that we can optimize it. I've never seen my type of solution to finding error codes, I've only ever seen lists which as you mention become out-of-date over time.

Offline

 

#6 2009-08-16 06:32:27 pm

Adam Bell
Administrator
From:: Nova Scotia, Canada
Registered: 2005-10-04
Posts: 4663

Re: Mac Error Codes

If I find the energy (we're in the midst of a very humid heat wave -- at least by Canadian standards) I'll write a script to run down my list, parse out the number, run your code (with the top modified) and compare results. See what's changed. wink


iMac running OS X 10.13.1

Offline

 

#7 2009-11-08 10:29:12 pm

ehunt123
Member
Registered: 2009-10-17
Posts: 12

Re: Mac Error Codes

This is a great piece of code for a similar purpose:

http://bitbucket.org/boredzo/error-lookup-tool/

Offline

 

#8 2010-09-01 07:52:37 am

Nigel Garvey
Moderator
From:: Warwickshire, England
Registered: 2002-11-20
Posts: 4621

Re: Mac Error Codes

regulus6633 wrote:

I posted this just for the process of people being able to check my code so that we can optimize it.


Well, I've been doodling at this for a couple of days and have come up with the version below. The optimisations are mainly inconsequential alterations to the text handlers. The most interesting change, perhaps, is the use of the "find" shell script's own parameters to do the filtering which was done by an AppleScript repeat in the original. (The repeat's still there, though, to build the Carbon/Cocoa list.) I haven't fooled with the process which reads the error files as I don't understand it yet!  roll

I'm afraid the optimisations make no difference at all to the user experience! The initial search for the files still takes a few seconds.

Applescript:

-- This script will search the error code files on your computer
-- explanation about error code files was found here:
-- [url]http://developer.apple.com/documentation/Cocoa/Conceptual/ErrorHandlingCocoa/ErrorHandling/ErrorHandling.html[/url]


property errorNum : ""
global errorFilesList, errorFilesDomain, errorFilesNames

(*============= COMPILE A LIST OF ALL THE ERROR FILES FOUND ON YOUR COMPUTER =============*)
-- 3 lists are made in this section; errorFilesList, errorFilesDomain, and errorFilesNames

set errorFilesList to {"/usr/include/mach/kern_return.h", "/usr/include/sys/errno.h"}
set errorFilesDomain to {"Mach", "POSIX"}

-- find the errors.h files in the /System/Library/Frameworks directory
-- add them to the errorFilesList but filter out known unusable files and add Cocoa/Carbon for each in the errorFilesDomain list
-- the unusable files do not contain error code numbers at all so we ignore them
-- So: items in the /System/Library/Frameworks/ heirarchy whose names end (case-insensitively) with "errors.h" but do not end with "NSErrors.h" or "DRCoreErrors.h" and don't have "Python.framework" in their paths.
set errorFilesList to errorFilesList & paragraphs of (do shell script "find /System/Library/Frameworks/ -iname \\*errors.h -and \\! \\( -name \\*NSErrors.h -or -name \\*DRCoreErrors.h -or -path \\*Python.framework\\* \\)")

repeat with k from 3 to (count errorFilesList)
   if (item k of errorFilesList ends with "MacErrors.h") then
       set end of errorFilesDomain to "Carbon"
   else
       set end of errorFilesDomain to "Cocoa"
   end if
end repeat

-- get the list of file names
set errorFilesNames to getFileNames(errorFilesList)

repeat
   (*============= GET THE ERROR NUMBER FROM THE USER =============*)
   repeat
       display dialog "This will use all of the error header files on your computer to locate an error code for you." & return & return & "Please enter the error code to find:" default answer errorNum with icon note buttons {"Cancel", "OK"} default button "OK" with title "Error Codes"
       set {errorNum, button_pressed} to {text returned, button returned} of the result
       if errorNum is not "" then
           try
               set numCheck to errorNum as number
               exit repeat
           on error
               display dialog "Please enter only numbers!" buttons {"OK"} default button 1
           end try
       end if
   end repeat
   
   set formattedError to ""
   repeat with theCounter from 1 to (count of errorFilesList)
       set thisFile to item theCounter of errorFilesList
       
       try
           (*============= GREP THE FILES FOR THE ERROR NUMBER =============*)
           if (item theCounter of errorFilesNames) is "kern_return.h" then
               -- kern_return.h has the error description on multiple lines so we need to get a bunch of lines after the error number
               if (errorNum as number) is greater than or equal to 0 then
                   set cmd to "grep -w --after-context=20 " & quoted form of errorNum & space & quoted form of thisFile & " | grep -v " & quoted form of ("\\-" & errorNum) & " | /usr/bin/grep -wi --after-context=20 \"#define\""
               else
                   set cmd to "grep -w --after-context=20 " & quoted form of ("\\" & errorNum) & space & quoted form of thisFile & " | /usr/bin/grep -wi --after-context=20 \"#define\""
               end if
               set tempVar to do shell script cmd
               set text item delimiters to "*/"
               set tempVar to item 1 of (text items of tempVar)
               set text item delimiters to ""
               set errorParas to {tempVar}
           else
               if (errorNum as number) is greater than or equal to 0 then
                   set cmd to "grep -w " & quoted form of errorNum & space & quoted form of thisFile & " | grep -v " & quoted form of ("\\-" & errorNum)
               else
                   set cmd to "grep -w " & quoted form of ("\\" & errorNum) & space & quoted form of thisFile
               end if
               
               set tempVar to do shell script cmd
               set errorParas to paragraphs of tempVar
           end if
           
           repeat with j from 1 to (count of errorParas)
               set errorText to item j of errorParas
               (*============= REMOVE MISC CHARACTERS FROM THIS RESULT AND FORMAT IT =============*)
               set {errorDef, errorDesc} to parse_error_data(errorText)
               set aFormattedError to displayFormat(errorDef, errorDesc, theCounter)
               set formattedError to formattedError & return & aFormattedError
           end repeat
       end try
   end repeat
   
   (*============= GIVE THE RESULTS A FINAL FORMAT AND DISPLAY THEM =============*)
   if formattedError is not "" then set formattedError to finalFormat(formattedError)
   
   -- display the results
   if formattedError is "" then
       display dialog "The error numbered " & errorNum & " could not be found" buttons {"Quit", "Search Again"} default button 2
       if button returned of the result is "Quit" then exit repeat
   else
       set finalErrorSting to "Results for error number ---> " & errorNum & return & return & formattedError
       display dialog finalErrorSting buttons {"Quit", "Save Results", "Search Again"} default button 1
       set theButton to button returned of result
       if theButton is "Quit" then
           exit repeat
       else if theButton is "Save Results" then
           set saveFile to choose file name with prompt "Specify where you want the file saved." default name "untitled.txt"
           writeTo(finalErrorSting, saveFile, false, string)
           exit repeat
       end if
   end if
end repeat



(*===================== SUBROUTINES ===================*)
on writeTo(this_data, target_file, append_data, mode) -- append_data is true or false, mode is string etc. (no quotes around either)
   try
       set target_file to target_file as Unicode text
       if target_file does not contain ":" then set target_file to POSIX file target_file as Unicode text
       set the open_target_file to open for access file target_file with write permission
       if append_data is false then set eof of the open_target_file to 0
       write this_data to the open_target_file starting at eof as mode
       close access the open_target_file
       return true
   on error
       try
           close access file open_target_file
       end try
       return false
   end try
end writeTo

on parse_error_data(theString) -- Replaces remove_chars(theString, aChar).
   set errorDef to word 1 of theString
   if (theString contains "/*") then
       set {TIDs, text item delimiters} to {text item delimiters, "*"}
       set errorDesc to text item 2 of theString
       set text item delimiters to TIDs
       set b to 1
       repeat while (character b of errorDesc is space)
           set b to b + 1
       end repeat
       set e to (count errorDesc)
       repeat while (character e of errorDesc is space)
           set e to e - 1
       end repeat
       set errorDesc to text b thru e of errorDesc
   else
       set errorDesc to errorDef
   end if
   
   return {errorDef, errorDesc}
end parse_error_data

on getFileNames(theList_ofPaths)
   set z to {}
   set TIDs to text item delimiters
   set text item delimiters to "/"
   repeat with anItem in theList_ofPaths
       set end of z to text item -1 of anItem
   end repeat
   set text item delimiters to TIDs
   return z
end getFileNames

on displayFormat(errorDef, errorDesc, theCounter)
   set aFormattedError to "Error Domain: " & (item theCounter of errorFilesDomain) & return & "Error File Name: " & (item theCounter of errorFilesNames) & return & "Error Name: " & errorDef & return & "Error Description: " & errorDesc & return
   return aFormattedError
end displayFormat

on finalFormat(formattedError)
   set TIDs to text item delimiters
   set text item delimiters to return
   set formattedError to text from text item 2 to text item -2 of formattedError
   set text item delimiters to TIDs
   return formattedError
end finalFormat


NG

Offline

 

#9 2010-09-01 11:26:40 am

regulus6633
Member
From:: Taulov, Denmark
Registered: 2006-11-02
Posts: 1695
Website

Re: Mac Error Codes

That's good Nigel, thanks. I've been playing around with spotlight for the last week so it's in my mind. I think the fastest search would be to use spotlight. So I came up with a spotlight command to find the error files. I matched it to my original method and your revised method, and all 3 methods find the exact same files. Here's the spotlight command and the script runs extremely fast now! After running 1 search subsequent searches are instantaneous. There must be some caching thing going on.

Applescript:

set filter to "(kMDItemDisplayName == \"Errors.h\"w || kMDItemDisplayName == \"mig_errors.h\") && kMDItemDisplayName != \"DRCoreErrors.h\" && kMDItemDisplayName != \"NSErrors.h\""
set errorFilesList to paragraphs of (do shell script "mdfind -onlyin /System/Library/Frameworks " & quoted form of filter)

And here's the whole script now with the spotlight command. The formatting of the files is the crazy part. I have a hard time understanding it myself. Please optimize it if you can but it is fast as it is. I'm more interested in finding out if I made any mistakes... am I returning everything that needs to be returned? Because the code is so crazy I can't be certain it's 100% accurate.

Applescript:

-- This script will search the error code files on your computer
-- explanation about error code files was found here:
-- [url]http://developer.apple.com/documentation/Cocoa/Conceptual/ErrorHandlingCocoa/ErrorHandling/ErrorHandling.html[/url]


property errorNum : ""
global errorFilesList, errorFilesDomain, errorFilesNames

(*============= COMPILE A LIST OF ALL THE ERROR FILES FOUND ON YOUR COMPUTER =============*)
-- 3 lists are made in this section; errorFilesList, errorFilesDomain, and errorFilesNames

set errorFilesList to {"/usr/include/mach/kern_return.h", "/usr/include/sys/errno.h"}
set errorFilesDomain to {"Mach", "POSIX"}

-- add the Errors.h files in the /System/Library/Frameworks directory including the mig_errors.h file
-- the "w" option means filter by words where words are also denoted by transition from uppercase to lowercase too
-- this "w" option filters out almost all the unwanted "error.h" files like the ones in the "Python.framework" path
-- we also remove DRCoreErrors.h and NSErrors.h because they don't have any error codes in them
set theFilter to "(kMDItemDisplayName == \"Errors.h\"w || kMDItemDisplayName == \"mig_errors.h\") && kMDItemDisplayName != \"DRCoreErrors.h\" && kMDItemDisplayName != \"NSErrors.h\""
set errorFilesList to errorFilesList & paragraphs of (do shell script "mdfind -onlyin /System/Library/Frameworks " & quoted form of theFilter)

-- add Cocoa/Carbon to errorFilesDomain for each file in errorFilesList
repeat with i from 3 to (count of errorFilesList)
   if (item i of errorFilesList) ends with "MacErrors.h" then
       set end of errorFilesDomain to "Carbon"
   else
       set end of errorFilesDomain to "Cocoa"
   end if
end repeat

-- get the list of file names
set errorFilesNames to getFileNames(errorFilesList)

repeat
   (*============= GET THE ERROR NUMBER FROM THE USER =============*)
   repeat
       display dialog "This will use all of the error header files on your computer to locate an error code for you." & return & return & "Please enter the error code to find:" default answer errorNum with icon note buttons {"Cancel", "OK"} default button "OK" with title "Error Codes"
       set {errorNum, button_pressed} to {text returned, button returned} of the result
       if errorNum is not "" then
           try
               set numCheck to errorNum as number
               exit repeat
           on error
               display dialog "Please enter only numbers!" buttons {"OK"} default button 1
           end try
       end if
   end repeat
   
   set formattedError to ""
   repeat with theCounter from 1 to (count of errorFilesList)
       set thisFile to item theCounter of errorFilesList
       
       try
           (*============= GREP THE FILES FOR THE ERROR NUMBER =============*)
           if (item theCounter of errorFilesNames) is "kern_return.h" then
               -- kern_return.h has the error description on multiple lines so we need to get a bunch of lines after the error number
               if (errorNum as number) is greater than or equal to 0 then
                   set cmd to "grep -w --after-context=20 " & quoted form of errorNum & space & quoted form of thisFile & " | grep -v " & quoted form of ("\\-" & errorNum) & " | /usr/bin/grep -wi --after-context=20 \"#define\""
               else
                   set cmd to "grep -w --after-context=20 " & quoted form of ("\\" & errorNum) & space & quoted form of thisFile & " | /usr/bin/grep -wi --after-context=20 \"#define\""
               end if
               set tempVar to do shell script cmd
               set text item delimiters to "*/"
               set tempVar to item 1 of (text items of tempVar)
               set text item delimiters to ""
               set errorParas to {tempVar}
           else
               if (errorNum as number) is greater than or equal to 0 then
                   set cmd to "grep -w " & quoted form of errorNum & space & quoted form of thisFile & " | grep -v " & quoted form of ("\\-" & errorNum)
               else
                   set cmd to "grep -w " & quoted form of ("\\" & errorNum) & space & quoted form of thisFile
               end if
               
               set tempVar to do shell script cmd
               set errorParas to paragraphs of tempVar
           end if
           
           repeat with j from 1 to (count of errorParas)
               set errorText to item j of errorParas
               
               (*============= REMOVE MISC CHARACTERS FROM THIS RESULT AND FORMAT IT =============*)
               set theChars to {return, tab, "*", "/", "#define", "=", ",", errorNum, space}
               repeat with aChar in theChars
                   set errorText to remove_chars(errorText, aChar)
               end repeat
               
               set aFormattedError to displayFormat(errorText, theCounter)
               set formattedError to formattedError & return & aFormattedError
           end repeat
       end try
   end repeat
   
   (*============= GIVE THE RESULTS A FINAL FORMAT AND DISPLAY THEM =============*)
   if formattedError is not "" then set formattedError to finalFormat(formattedError)
   
   -- display the results
   if formattedError is "" then
       display dialog "The error numbered " & errorNum & " could not be found" buttons {"Quit", "Search Again"} default button 2
       if button returned of the result is "Quit" then exit repeat
   else
       set finalErrorSting to "Results for error number ---> " & errorNum & return & return & formattedError
       display dialog finalErrorSting buttons {"Quit", "Save Results", "Search Again"} default button 1
       set theButton to button returned of result
       if theButton is "Quit" then
           exit repeat
       else if theButton is "Save Results" then
           set saveFile to choose file name with prompt "Specify where you want the file saved." default name "untitled.txt"
           writeTo(finalErrorSting, saveFile, false, string)
           exit repeat
       end if
   end if
end repeat



(*===================== SUBROUTINES ===================*)
on writeTo(this_data, target_file, append_data, mode) -- append_data is true or false, mode is string etc. (no quotes around either)
   try
       set target_file to target_file as Unicode text
       if target_file does not contain ":" then set target_file to POSIX file target_file as Unicode text
       set the open_target_file to open for access file target_file with write permission
       if append_data is false then set eof of the open_target_file to 0
       write this_data to the open_target_file starting at eof as mode
       close access the open_target_file
       return true
   on error
       try
           close access file open_target_file
       end try
       return false
   end try
end writeTo

on remove_chars(theString, aChar)
   set {TIDs, text item delimiters} to {text item delimiters, aChar}
   set a to text items of theString
   set b to {}
   repeat with i from 1 to (count of a)
       if item i of a is not "" then
           set end of b to item i of a
       end if
   end repeat
   set text item delimiters to space
   set c to b as text
   set text item delimiters to TIDs
   return c
end remove_chars

on getFileNames(theList_ofPaths)
   set z to {}
   set text item delimiters to "/"
   repeat with anItem in theList_ofPaths
       set end of z to (item -1 of (text items of anItem))
   end repeat
   set text item delimiters to ""
   return z
end getFileNames

on displayFormat(a, theCounter)
   set text item delimiters to space
   set b to text items of a
   set errorDef to item 1 of b
   try
       set errorDesc to (items 2 thru -1 of b) as text
   on error
       set errorDesc to errorDef
   end try
   set text item delimiters to ""
   set aFormattedError to "Error Domain: " & (item theCounter of errorFilesDomain) & return & "Error File Name: " & (item theCounter of errorFilesNames) & return & "Error Name: " & errorDef & return & "Error Description: " & errorDesc & return
   return aFormattedError
end displayFormat

on finalFormat(formattedError)
   set text item delimiters to return
   set b to text items of formattedError
   set b to items 2 thru -2 of b
   set formattedError to b as text
   set text item delimiters to ""
   return formattedError
end finalFormat

Last edited by regulus6633 (2010-09-01 01:26:17 pm)

Offline

 

#10 2010-09-01 12:04:46 pm

Nigel Garvey
Moderator
From:: Warwickshire, England
Registered: 2002-11-20
Posts: 4621

Re: Mac Error Codes

Yep. That's certainly faster!  smile

I had to change filter to |filter| to avoid a clash with a Satimage command.


NG

Offline

 

#11 2010-09-01 01:29:01 pm

regulus6633
Member
From:: Taulov, Denmark
Registered: 2006-11-02
Posts: 1695
Website

Re: Mac Error Codes

Nigel Garvey wrote:

Yep. That's certainly faster!  smile

I had to change filter to |filter| to avoid a clash with a Satimage command.


Yes it is! I can't believe I didn't do this earlier. I use this script fairly frequently and it was always a pain to wait for it to open. BTW, I changed filter to theFilter in the above script to make sure no one else runs into that problem. Thanks.

Offline

 

#12 2014-07-19 08:01:05 pm

cdenesha
Member
Registered: 2010-08-25
Posts: 2

Re: Mac Error Codes

VERY nice script!

I found this page from a web search and felt inclined to try it, but it did not work. I searched my drive and had no header files! It turns out Mavericks does not install them by default.. and this was an upgrade from ML.

Taking a hint from http://stackoverflow.com/questions/1958 … -directory I used Xcode and ran the

Applescript:

xcode-select --install

command to install them. The script now works without changes!

I do suggest trying this with a fresh Mavericks install and catching this as an error with a solution message.. I don't have another Mac right now so I can't do it.

thanks,

chris

Offline

 

#13 2014-07-20 04:38:44 pm

Nigel Garvey
Moderator
From:: Warwickshire, England
Registered: 2002-11-20
Posts: 4621

Re: Mac Error Codes

Thanks for updating this topic, Chris!


NG

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)