Quantcast
Channel: Adobe Community: Message List - InDesign Scripting
Viewing all articles
Browse latest Browse all 37788

use bridgeTalk with onError event, exception handling

$
0
0

Hi all,

 

I'm writting a function who use bridgeTalk to execute a photoshop script. This function works but I would like to throw an exception if the script has a problem. I commented a line in my script to have an exception but the onError event doesn't throw my Error.

 

Have someone an idea?

 

Thanks!

 

 

 

function save_to_PSD(obj){    var bt = new BridgeTalk();     bt.target = "photoshop";     bt.body = save_to_psd_function.toSource()+"("+obj.toSource()+");";     bt.onError = function(errObj) {        // the next line display the error in the console        $.writeln(errObj.body);        // PROBLEM this error is never throw         throw new Error (errObj.body);     };     bt.send(100);
}


function save_to_psd_function(serializedObject){
    app.displayDialogs = DialogModes.NO;    var obj = eval(serializedObject);    var file_path = decodeURI(obj.file_path);    // this will generate an exception    //var img_file = new File(file_path);    var ps_doc = app.open(img_file);    psdSaveOption = new PhotoshopSaveOptions();    psdSaveOption.embedColorProfile = true;    app.activeDocument.saveAs(img_file, psdSaveOption, true, Extension.LOWERCASE);    ps_doc.close();        app.displayDialogs = DialogModes.ALL;
}

Viewing all articles
Browse latest Browse all 37788

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>