Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filer executes opt_errorHandler only if INVALID_MODIFICATION_ERR? #22

Open
alinnert opened this issue Oct 24, 2012 · 0 comments
Open

filer executes opt_errorHandler only if INVALID_MODIFICATION_ERR? #22

alinnert opened this issue Oct 24, 2012 · 0 comments

Comments

@alinnert
Copy link

What I wanted to do: Create a directory and execute a function afterwards, but do something else if the folder aldready exists. So I thought I can pass function 1 as successCallback and the second function as opt_errorHandler that will be executed if the folder already exists. But it didn't work.

So I inspected the source code of filer.js and discovered that opt_errorHandler will only be executed if(e.code == FileError.INVALID_MODIFICATION_ERR). Otherwise nothing happens.

MDN says this error will occur if you do things like copy a folder into itself or moving a file into the same folder where it already resides without changing the filename. In a function like mkdir() this will never happen. So opt_errorHandler will never be called. And the same issue goes for create() as well.

If I change INVALID_MODIFICATION_ERR to FileError.PATH_EXISTS_ERR it works all fine.

Is there a reason why it is handled this way? Or wouldn't it be even better if opt_errorHandler is called no matter what the value e.code is? So developers can choose what to do if an error occurs and even do different things, depending on the error code.

Now, I haven't checked all the other functions but I think all of them should behave like that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant