Distinguish error profiles from correct ones
SimonLab opened this issue · 4 comments
At the moment we are returning an object containing all the information of a profile. When there is an error (wrong url for example) we also return on object with only the url as a property. It will be nice to be able to know if a profile is correct or not. Can we add a property to the object, for example 'parse-error'.
see L8
Good question @SimonLab the "standard" way of doing this is to return error as the first parameter of the callback
...
any reason you would not simply set the error
to an object e.g:
{
"type":"parse error",
"message":"failed to parse the profile page",
"code":400
}
Or something like that...
then in the code that uses this module:
var LP = require('linkedin-public-profile-parser');
var url = 'https://uk.linkedin.com/in/random-profile-we-know-will-fail';
LP(url, function(err, data){
if(err && err.code === 400) {
errorhandler(err);
}
else {
useDataForSomething(data); // what evs.
}
})
Yes it's better to to check the error parameter of the callback and not include an error code on the data object itself. I forget for a moment that the callback manage the error. Thanks @nelsonic for the reminder.
Sweet. 😉
let me know if you need any help writing tests or if you just want to write a quick PR, I'm here to review/help/merge. 👍