Question
How to break try/catch when all tasks in try are not completed
I try to flatten img and to check is there any shadows selection after i contract selection dor 2px, in case that it is true i want to inform that there is a selection, in other case i want to cacth erorr and alert there is no selection. Problem is that even there is no selection script still complete some steps from try. Is it possible to break somehow if result of try is false?
There is my code. Thanks in advance
try{
// FLATTEN IMAGE
var idFltI = charIDToTypeID( "FltI" );
executeAction( idFltI, undefined, DialogModes.NO );
//// Select Shadows
var idClrR = charIDToTypeID( "ClrR" );
var desc22 = new ActionDescriptor();
var idClrs = charIDToTypeID( "Clrs" );
var idClrs = charIDToTypeID( "Clrs" );
var idShdw = charIDToTypeID( "Shdw" );
desc22.putEnumerated( idClrs, idClrs, idShdw );
var idshadowsFuzziness = stringIDToTypeID( "shadowsFuzziness" );
desc22.putInteger( idshadowsFuzziness, 20 );
var idshadowsUpperLimit = stringIDToTypeID( "shadowsUpperLimit" );
desc22.putInteger( idshadowsUpperLimit, 65 );
var idcolorModel = stringIDToTypeID( "colorModel" );
desc22.putInteger( idcolorModel, 0 );
executeAction( idClrR, desc22, DialogModes.NO );
////// Contract selection
var idCntc = charIDToTypeID( "Cntc" );
var desc25 = new ActionDescriptor();
var idBy = charIDToTypeID( "By " );
var idPxl = charIDToTypeID( "#Pxl" );
desc25.putUnitDouble( idBy, idPxl, 2.000000 );
var idselectionModifyEffectAtCanvasBounds = stringIDToTypeID( "selectionModifyEffectAtCanvasBounds" );
desc25.putBoolean( idselectionModifyEffectAtCanvasBounds, false );
executeAction( idCntc, desc25, DialogModes.NO );
alert("There is shadows")
}
catch(e){
alert("There is no selection")
}
