You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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 asopt_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 executedif(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. Soopt_errorHandler
will never be called. And the same issue goes forcreate()
as well.If I change
INVALID_MODIFICATION_ERR
toFileError.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.
The text was updated successfully, but these errors were encountered: