HubSpot / messenger

Growl-style alerts and messages for your app. #hubspot-open-source
http://github.hubspot.com/messenger/
MIT License
4.03k stars 408 forks source link

errorMessage cannot be overridden #56

Open samdobson opened 10 years ago

samdobson commented 10 years ago
msg = Messenger().run({
    successMessage: 'User added',
    progressMessage: 'Adding user...',
    errorMessage: 'Error adding user'
}, {
    url: '/add-user',
    type: 'POST',
    success: function (xhr) {
        return xhr.data.username + ' added';
    },
    error: function (xhr) {
        error_message = xhr.responseJSON.message;
        return msg.update({
            message: error_message, //' *THIS IS NEVER DISPLAYED!* 
            type: 'error',
            actions: {
                undo: {
                    label: 'upgrade',
                    action: function () {
                        alert('Account upgraded');
                    }
                }
            }
        });
    }
});

Expected result on error: error_message is displayed. Actual result on error: errorMessage is always displayed instead of the error message returned from the server (error_message).

zackbloom commented 10 years ago

Do you mind removing the msg.update call, and just returning the new options object from your error handler instead?