Important: The information in this document is obsolete and should not be used for new development.
OSAScriptError
You can use theOSAScriptError
function to get information about errors that occur during script execution.
FUNCTION OSAScriptError(scriptingComponent: ComponentInstance; selector: OSType; desiredType: DescType; VAR resultingErrorDescription: AEDesc) : OSAError;
scriptingComponent
- A component instance created by a prior call to the Component Manager function
OpenDefaultComponent
orOpenComponent
(see page 10-4).selector
- A value that determines what
OSAScriptError
returns. The value can be one of these constants:CONST kOSAErrorNumber = 'errn'; kOSAErrorMessage = 'errs'; kOSAErrorBriefMessage = 'errb'; kOSAErrorApp = 'erap'; kOSAErrorPartialResult = 'ptlr'; kOSAErrorOffendingObject = 'erob'; kOSAErrorRange = 'erng';
desiredType
- The desired descriptor type of the resulting descriptor record. The description that follows explains how this is determined by the value passed in the
selector
parameter.resultingErrorDescription
- The resulting descriptor record.
DESCRIPTION
Whenever theOSAExecute
function returns the errorerrOSAScriptError
, you can use theOSAScriptError
function to get more specific information about the error from the scripting component that encountered it. (This information remains available only until the next call to the same scripting component.) The information returned byOSAScriptError
depends on the value passed in theselector
parameter, which also determines the descriptor type you should specify in thedesiredType
parameter.Every scripting component should support calls to
OSAScriptError
that passkOSAErrorNumber
,kOSAErrorMessage
, orkOSAErrorPartialResult
in theselector
parameter.Some scripting components may also support calls that pass other values in the
selector
parameter, includingkOSAErrorRange
, which provides start and end positions delimiting the errant expression in the source data. If the value of the selector parameter iskOSAErrorRange
, the value ofdesiredType
must betypeOSAErrorRange
.
CONST typeOSAErrorRange = 'erng';A descriptor record of typetypeOSAErrorRange
is an AE record that consists of two descriptor records oftypeShortInteger
specified by these keywords:
CONST keyOSASourceStart = 'srcs'; {start of error range} keyOSASourceEnd = 'srce'; {end of error range}If the value of theselector
parameter is kOSAErrorNumber
, scripting components may return, in theresultingErrorDescription
parameter, one of these general error codes:
errOSACantCoerce -1700 Same as errAECoercionFail
; can't coerce data to requested descriptor typeerrOSACantAccess -1728 Same as errAENoSuchObject
; runtime error in resolution of object specifier recorderrOSAGeneralError -2700 General runtime error errOSADivideByZero -2701 Attempt to divide by zero errOSANumericOverflow -2702 Numeric overflow errOSACantLaunch -2703 Can't launch specified file because it isn't an application errOSAAppNotHighLevelEventAware -2704 Doesn't respond to Apple events errOSACorruptTerminology -2705 The application has a corrupted 'aete'
resourceerrOSAStackOverflow -2706 Stack overflow errOSAInternalTableOverflow -2707 Internal table overflow errASDataBlockTooLarge -2708 Attempt to create a value larger than the allowable size errOSATypeError -1703 Same as errAEWrongDataType
; wrong descriptor typeerrOSAMessageNotUnderstood -1708 Same as errAEEventNotHandled
; event not handled or message not understooderrOSAUndefinedMessage -1717 Same as errAEHandlerNotFound
; handler not found for messageerrOSAIllegalIndex -1728 Same as errAEIllegalIndex
; not a valid indexerrOSAIllegalRange -2720 Same as errAEImpossibleRange; range of specified objects not possible errOSASyntaxError -2740 General syntax error errOSASyntaxTypeError -2741 Syntax error; parser expected one type but found another errOSATokenTooLong -2742 Identifier too long errOSAMissingParameter -1701 Same as errAEDescNotFound
; descriptor record not founderrOSAParameterMismatch -1721 Same as errAEWrongNumberArgs
; wrong number of argumentserrOSADuplicateParameter -2750 Parameter specified more than once errOSADuplicateProperty -2751 Property specified more than once errOSADuplicateHandler -2752 Handler defined more than once errOSAUndefinedVariable -2753 Undefined variable errOSAInconsistentDeclarations -2754 Inconsistent declarations errOSAControlFlowError -2755 Control flow error Although scripting components are not required to support these error codes, their use simplifies error handling for applications that run scripts created by multiple components.
If the value of the
selector
parameter is kOSAErrorNumber, the AppleScript component may return, in theresultingErrorDescription
parameter, one of these error codes:SPECIAL CONSIDERATIONS
If you callOSAScriptError
using an instance of the generic scripting component, the generic scripting component uses the same instance of a scripting component that it used for the previous call.RESULT CODES
SEE ALSO
For an example of the use ofOSAScriptError
, see Listing 10-3 on page 10-11.