try catch with jsCallback

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
rodneyt
Posts: 128
Joined: Wed Oct 17, 2018 7:32 am

try catch with jsCallback

Post by rodneyt » Wed Sep 07, 2022 11:25 am

You can do something like this at Chrome console

Code: Select all

try { ...your javascript here... } catch (error) {'0'}
.. but it seems JSCallback doesn't like try/catch. Has anyone observed this before, perhaps I am doing something wrong?

Rod

rodneyt
Posts: 128
Joined: Wed Oct 17, 2018 7:32 am

Re: try catch with jsCallback

Post by rodneyt » Sat Sep 10, 2022 1:59 am

The solution is to wrap in a function like this

Code: Select all

function getActiveOB3EntityName () {
    let tDocName
    try {
            tDocName = io.openbook.viewport.Application.getActiveTab().record.data.properties.title
        }
            catch (error) {
            tDocName ='error';
    }
    return tDocName
}

getActiveOB3EntityName();


Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”