It checks if Path name exists and if so, select it and move it to top
executeAction will not send error.
myPathNameToTop('Shine');
function myPathNameToTop(name) {
$.level =0; // only if you are using this from ESTK (it can be removed when running from photoshop)
try {
var myPath = app.activeDocument.pathItems.getByName (name);
} catch(e) {}
$.level =1;
if (String(myPath) != "undefined") { // if exists move to top
myPath.select();
var desc25 = new ActionDescriptor();
var ref23 = new ActionReference();
ref23.putEnumerated( charIDToTypeID( "Path" ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );
desc25.putReference( charIDToTypeID( "null" ), ref23 );
var ref24 = new ActionReference();
ref24.putIndex( charIDToTypeID( "indx" ), 0 );
desc25.putReference( charIDToTypeID( "T " ), ref24 );
executeAction( charIDToTypeID( "move" ), desc25, DialogModes.NO );
}
}