In NativeFileSystem.js the _nativeToFileError maps native file errors to HTML5 File Errors.
The specification states that for any errors that dont have a direct mapping, SECURITY_ERR should be used.
The following native errors are mapped to SECURITY_ERR:
- ERR_UNKNOWN
- ERR_INVALID_PARAMS
- ERR_UNSUPPORTED_ENCODING
This can make debugging errors difficult, as it requires developers to edit NativeFileSystem.js in order to see what the actual error is.
Looking at the w3c FileSystem specification that we appear to be following:
http://www.w3.org/TR/2011/WD-file-system-api-20110419/#error-code-descriptions
There is a NOT_READABLE_ERR, which is describe as:
user agent must use this code if a file or directory cannot be read, typically due due to permission problems that occur after a reference to a file has been acquired (e.g. concurrent lock with another application).
Which suggest that it should only be used for "permission problems".
However, looking at the most recent specification:
http://www.w3.org/TR/file-system-api/#definitions
The NOT_READABLE_ERR is describe as being for:
A required file or directory could be read.
So, I think we should map the native ERR_UNSUPPORTED_ENCODING error to the HTML / JavaScript NOT_READABLE_ERR, as it seems to map closer than SECURITY_ERR does.