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

Decoding HTTP error messages #1

Open
lxbarth opened this issue May 23, 2011 · 1 comment
Open

Decoding HTTP error messages #1

lxbarth opened this issue May 23, 2011 · 1 comment

Comments

@lxbarth
Copy link
Contributor

lxbarth commented May 23, 2011

Since bones API endpoints error returns are standardized to return a hash containing a message and a status property, should we decode these hashes in Admin.bones' error function?.

Something like:

error: function(model, resp) {
    var message = resp;
    if (resp instanceof Object && resp.responseText) {
        var obj = JSON.parse(resp.responseText);
        if (obj.message) {
            message = obj.message
        }
    }
    new views['AdminGrowl']({
        message: message,
        classes: 'error',
        autoclose: 0
    });
}
@lxbarth
Copy link
Contributor Author

lxbarth commented May 24, 2011

I just committed a first shot at this: 7945319

Here's how this code simplifies error reporting in bones-auth: developmentseed/bones-auth@adacd9a

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