Skip to content

Conversation

@NicolasBonduel
Copy link
Member

@NicolasBonduel NicolasBonduel commented Jan 27, 2020

This change update the way we handle errors.

Errors will now always return a message under the error.message key. We will only return our own errors instead of SuperAgent errors.
This allows for having a human-readable and front facing error in all cases.

const Builton = require('@builton/node-sdk');
const b = new B({
    apiKey: '---apiKey---',
});
b.products.get('doesntexist').catch(e => {
    console.log({
        name: e.name, message: e.message, status: e.status
    });
});
// Before: 
// output: { name: 'Error', message: 'Not Found', status: 404 }
// After
// output: { name: 'BadRequest', message: 'Getting product failed.', status: 404 }

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

Successfully merging this pull request may close these issues.

4 participants