How to safely ignore or deal with an error in extendscript?
Hi all,
I'm working on a script that looks to see if the selected frame in InDesign has particular coordinates, dimensions and object style. If it finds a match it gives it a name (e.g. 1C7). At the moment it gives me an alert to show the result but eventually I'll turn the alert off and use the result as a variable in Keyboard Maestro to do more exciting things.
One small issue I have is that when the script DOESN'T find any match, I get this error.

Is there a way to ignore the error or circumvent it in the first place?
var myDoc = app.activeDocument;
//SELECTED OBJECT
mySelection = myDoc.selection[0];
//SELECTED OBJECT'S STYLE
frameObjectStyle = mySelection.appliedObjectStyle.name;
//OBJECT STYLES TO FIND
objStyle1 = "Text Frame Inset 4mm";
objStyle2 = "Text Frame Inset 4mm 2 column";
//FIX THE GEOMETRIC BOUNDS
var gb = app.activeDocument.selection[0].geometricBounds;
var xcoord = gb[1].toFixed(2);
var ycoord = gb[0].toFixed(2);
var width = gb[3].toFixed(2) - gb[1].toFixed(2);
var height = gb[2].toFixed(2) - gb[0].toFixed(2);
//NOW FIND THE TYPE AND POSITION OF THE SELECTED FRAME
//RETURN A POSITIVE HIT AS TEXT
//2 COLUMN TEXT FRAMES
//2C1 top of left page
if (xcoord == 11 && ycoord == 11 &&
width == 148 && height == 107 && frameObjectStyle === objStyle2)
{result = "2C1"};
//2C2 bottom of left page
if (xcoord == 11 && ycoord == 122 &&
width == 148 && height == 107 && frameObjectStyle === objStyle2)
{result = "2C2"};
//2C3 top of right page
if (xcoord == 181 && ycoord == 11 &&
width == 148 && height == 107 && frameObjectStyle === objStyle2)
{result = "2C3"};
//2C4 bottom of right page
if (xcoord == 181 && ycoord == 122 &&
width == 148 && height == 107 && frameObjectStyle === objStyle2)
{result = "2C4"};
//1 COLUMN TEXT FRAMES
//1C1 top left of left page
if (xcoord == 11 && ycoord == 11 &&
width == 72 && height == 107 && frameObjectStyle == objStyle1)
{result = "1C1"};
//1C2 top right of left page
if (xcoord == 87 && ycoord == 11
&& width == 72 && height == 107 && frameObjectStyle == objStyle1)
{result = "1C2"};
//1C3 bottom left of left page
if (xcoord == 11 && ycoord == 122
&& width == 72 && height == 107 && frameObjectStyle == objStyle1)
{result = "1C3"};
//1C4 bottom right of left page
if (xcoord == 87 && ycoord == 122
&& width == 72 && height == 107 && frameObjectStyle == objStyle1)
{result = "1C4"};
//1C5 top left of right page
if (xcoord == 181 && ycoord == 11
&& width == 72 && height == 107 && frameObjectStyle == objStyle1)
{result = "1C5"};
//1C6 top right of right page
if (xcoord == 257 && ycoord == 11
&& width == 72 && height == 107 && frameObjectStyle == objStyle1)
{result = "1C6"};
//1C7 bottom left of right page
if (xcoord == 181 && ycoord == 122
&& width == 72 && height == 107 && frameObjectStyle == objStyle1)
{result = "1C7"};
//1C8 bottom right of right page
if (xcoord == 257 && ycoord == 122
&& width == 72 && height == 107 && frameObjectStyle == objStyle1)
{result = "1C8"};
alert (result);Many thanks if anyone can help.
