You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by cfjedimaster <gi...@git.apache.org> on 2014/04/09 15:38:18 UTC

[GitHub] cordova-plugin-file pull request: Add error codes.

GitHub user cfjedimaster opened a pull request:

    https://github.com/apache/cordova-plugin-file/pull/37

    Add error codes.

    I find myself constantly checking the source code to see what each error code represents. I think this should be in the core doc. I'd like to actually add a bit more text, for example, explaining what an encoding error could mean, but for now I figure this is a good start.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/cfjedimaster/cordova-plugin-file patch-2

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/cordova-plugin-file/pull/37.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #37
    
----
commit b52476b58b847d10d7ec6e07f268ca7948f876e6
Author: Raymond Camden <ra...@gmail.com>
Date:   2014-04-09T13:38:11Z

    Add error codes.
    
    I find myself constantly checking the source code to see what each error code represents. I think this should be in the core doc. I'd like to actually add a bit more text, for example, explaining what an encoding error could mean, but for now I figure this is a good start.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cordova-plugin-file pull request: Add error codes.

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/cordova-plugin-file/pull/37


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cordova-plugin-file pull request: Add error codes.

Posted by aogilvie <gi...@git.apache.org>.
Github user aogilvie commented on the pull request:

    https://github.com/apache/cordova-plugin-file/pull/37#issuecomment-40347485
  
    +1 error codes and +1 @purplecabbage. Though `console.error(` would be your friend there.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cordova-plugin-file pull request: Add error codes.

Posted by purplecabbage <gi...@git.apache.org>.
Github user purplecabbage commented on the pull request:

    https://github.com/apache/cordova-plugin-file/pull/37#issuecomment-40001813
  
    +1
    It may be good to provide a better example of error handling as well. I would expect having a function like this that you could just copy into your code would also help.
    
    ```
    function handleError(err) {
        switch(err) {
            case FileError.NOT_FOUND_ERR :
                console.log("FileError.NOT_FOUND_ERR");
                break;
            case FileError.SECURITY_ERR :
                console.log("FileError.SECURITY_ERR");
                break;        
            case FileError.ABORT_ERR :
                console.log("FileError.ABORT_ERR");
                break;        
            case FileError.NOT_READABLE_ERR : 
                console.log("FileError.NOT_READABLE_ERR");
                break;        
            case FileError.ENCODING_ERR :
                console.log("FileError.ENCODING_ERR");
                break;        
            case FileError.NO_MODIFICATION_ALLOWED_ERR :
                console.log("FileError.NO_MODIFICATION_ALLOWED_ERR");
                break;        
            case FileError.INVALID_STATE_ERR :
                console.log("FileError.INVALID_STATE_ERR");
                break;        
            case FileError.SYNTAX_ERR :
                console.log("FileError.SYNTAX_ERR");
                break;        
            case FileError.INVALID_MODIFICATION_ERR :
                console.log("FileError.INVALID_MODIFICATION_ERR");
                break;        
            case FileError.QUOTA_EXCEEDED_ERR :
                console.log("FileError.QUOTA_EXCEEDED_ERR");
                break;        
            case FileError.TYPE_MISMATCH_ERR :
                console.log("FileError.TYPE_MISMATCH_ERR");
                break;        
            case FileError.PATH_EXISTS_ERR :
                console.log("FileError.PATH_EXISTS_ERR");
                break;
        }
    }
    ```
      


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cordova-plugin-file pull request: Add error codes.

Posted by mattgrande <gi...@git.apache.org>.
Github user mattgrande commented on the pull request:

    https://github.com/apache/cordova-plugin-file/pull/37#issuecomment-39973865
  
    +1. I couldn't find this documented anywhere!


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cordova-plugin-file pull request: Add error codes.

Posted by raztus <gi...@git.apache.org>.
Github user raztus commented on the pull request:

    https://github.com/apache/cordova-plugin-file/pull/37#issuecomment-40286432
  
    Here's what I've used successfully:
    
    ```
        var errorMsgs = {},
            code = "";
        for (var static in FileError) {
            code = FileError[static];
            errorMsgs[code] = static;
        }
    ```
    
    Now `errorMsgs` is a map with the code as the key, so you can do `var msg = "Error: " + errorMsgs[err.code]` in your error handler.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---