Adobe 65007312 - Photoshop Lightroom Programmer's Manual page 18

Mac
Hide thumbs Also See for 65007312 - Photoshop Lightroom:
Table of Contents

Advertisement

C
1: Using the Lightroom SDK
HAPTER
Accessing object functions and properties
A few classes (
allow you to call some functions directly in the imported namespace, using dot notation. By convention,
the documentation uses lowercase names, as well as colon notation, to indicate that a function is called on
an instance. For example:
LrFtp.appendFtpPaths() -- A namespace function
ftpConnection:path() -- An object function
Classes define both functions and properties. To access properties in objects, use the dot notation. Again,
the documentation uses the lowercase naming convention to indicate an instance of a class:
exportRendition.photo -- An object property
A property can have no value; a nil property value is not the equivalent of false, zero, or the empty string.
Setting a nil value for a property that has a default value causes the property to revert to the default.
Using function contexts for error handling
The
LrFunctionContext
Use
LrFunctionContext.callWithContext()
number of handler functions to the call that respond to errors that may occur during the execution of the
wrapped function, or clean up resources regardless of how the wrapped function terminates. If you attach
multiple cleanup or error handlers to the wrapped function, the handlers are called in reverse order of
attachment.
Some of the functions in
error reporting behavior. For instance,
LrDialogs.attachErrorDialogToFunctionContext()
execution of the task are reported to the user and not silently forgotten. Lightroom provides predefined
error dialogs that you can customize with explanatory messages, as shown in the following example. You
can use
LrTasks.startAsyncTaskWithoutErrorHandler()
reporting instead.
Example: Function context with an error dialog
local LrDialogs = import 'LrDialogs'
local LrErrors = import 'LrErrors'
local LrFunctionContext = import 'LrFunctionContext'
LrFunctionContext.callWithContext( 'error handling demo', function ( context )
-- If an error is thrown during this function call context,
-- show a standard error dialog.
LrDialogs.attachErrorDialogToFunctionContext( context )
-- The code needed to perform your task goes here
-- For illustration, force an error here, throw error two different ways
if showInternalError then -- in some case
error "Example of an internal error" --call built-in error() function
else -- otherwise, use the LrErrors throw function
LrErrors.throwUserError( LOC "$$$/MyPlugin/Error/Example=Example of
end
end )
,
,
, and
LrFtp
LrView
LrXml
namespace and class is a programming utility for error handling.
work in conjunction with
LrTasks
LrFunctionContext
to wrap a function call. This allows you to attach any
LrFunctionContext
LrTasks.startAsyncTask()
. This ensures that errors that occur during the
The Lightroom SDK scripting environment 18
) act as both classes and namespaces, and
to provide standardized
calls
if you wish to provide your own error
a localized error message." )

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Photoshop lightroom sdk 3.0

Table of Contents