locked
how to handle error occurred when getFolderAsync?

    Question

  • Hello,

    I'm using storage.getFolderAsync method to find a folder like below

    try{
                    storage.getFolderAsync('CERT').then( function (folder) {
                        var x=1;
                    }, function (e) {
                        var z = 1;
                    }, function (f) {
                        var k = 1;
                    });
                } catch (e) {
                    Debugger.displayDebugMessage(e);
                }
                finally { }
    


    It works when there is a 'CERT' folder but it throws a runtime-exception when the folder does not exist. 

    The message is: "JavaScript runtime error: The system cannot find the file specified."

     

    How could I run the application through the error?

     

    Thanks,

    Sungsoo Moon

    Wednesday, November 30, 2011 3:27 AM

Answers

  • Hi Sungsoo,

    This is the correct code.  The try catch block will allow your application to continue to execute.  Try running your application, but not with the debugger and see what happens.

    -Jeff


    Jeff Sanders (MSFT)
    • Marked as answer by Sungsoo Moon Tuesday, December 06, 2011 7:21 AM
    Wednesday, November 30, 2011 1:19 PM
    Moderator

All replies

  • Hi Sungsoo,

    This is the correct code.  The try catch block will allow your application to continue to execute.  Try running your application, but not with the debugger and see what happens.

    -Jeff


    Jeff Sanders (MSFT)
    • Marked as answer by Sungsoo Moon Tuesday, December 06, 2011 7:21 AM
    Wednesday, November 30, 2011 1:19 PM
    Moderator
  • Thanks Jeff! It was very helpful :)

     

    Tuesday, December 06, 2011 7:20 AM