ebidel/filer.js

exception raised by filer.js cannot be catched.

Opened this issue · 2 comments

There is no way to catch exception in async code.

The reason it is impossible to catch exception raised in your library is because once the callback is called, the try/catch block is over.

Simple ex:

(foo.bar is not on filesystem)

    f = new Filer();
    f.init({persistent: true, size: 20*1024*1024}, function (fs)
    {
        manage_error = function (e) {console.log('error' + e);}
        try
        {
            f.open('foo.bar', function() { console.log('opened');}, manage_error);
        }
        catch (e)
        {
            // never execute!
            console.log(e.message);
        }
    });

So no way to test if a file exist or not, it is better not using exception and use only callback.

I think this is the same problem I postet in this issue - or similar to this one: #22
isn't it?

Yes I think that the problem is very similar to yours.
But I wanted to think more broadly.
The main problem is that the code outside the callback can not catch
exceptions so best not to use exceptions in asynchronous code.
Filer.js is a large library, but there are many problems (exceptions, cwd
changed during ls, etc.) support does not exist, I tried to contact
Bidelman but I got no response

2012/11/9 Andreas Linnert notifications@github.com

I think this is the same problem I postet in this issue - or similar to
this one: #22#22
isn't it?


Reply to this email directly or view it on GitHubhttps://github.com//issues/24#issuecomment-10225962.