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

Better error handling. #80

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

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.

3 participants