[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]


Processing Errors

When an AppleEvent is sent to CodeWarrior, errors may be returned to the script. Errors are not always evil occurrences, as sometimes you will want to trap errors to make your script do other things in response to the current conditions. For example, you can trap a file-not-found error and direct the CodeWarrior IDE to perform an alternate action as a result. Errors can be generated from the operating system, or from the application you're trying to script. Errors for the operating system are documented in Appendix C of the AppleScript Language Guide. Errors generated by the CodeWarrior IDE are documented here.

Errors are usually returned through the normal Error-return channel. However, for events that process a list of files, the errors are returned in the result (a built-in AppleScript variable). The list, with each member corresponding to an input file, is returned as the event's result with each list member.

In addition to operating system errors, such as out of memory errors, the error codes listed in Table A.1 may also be returned.

Table 0.1 CodeWarrior keyAEResult result codes (typeShortInteger)

 

Name
Value
noErr  
0  
errShell_ActionFailed  
1  
errShell_FileNotFound  
2  
errShell_DuplicateFile  
3  
errShell_CompileError  
4  
errShell_MakeFailed   (compile or link error)  
5  
errShell_NoOpenProject  
6  
errShell_WindowNotOpen  
7  
errShell_SegmentNotFound  
8  

The result parameter, keyAEResult, is not set if there is an error while interpreting the AppleEvent (running out of memory, supplying a bad parameter type, and so on). In such cases, an error code is returned in the standard keyErrorNumber parameter.

Listing A.3 gives an example of an AppleScript that handles an error.

Listing 0.3 Error handling in AppleScript


try
 tell application "CodeWarrior IDE"
  set doclist to (Get Open Documents)
 end tell
on error number errnum
 display dialog "Bummer!" & errnum
end try

To see more examples of error handling in scripts, review some of the scripts in the (Scripts) folder in the same folder as your CodeWarrior IDE application.


[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.

Last updated: August 02, 2000