Better Error Handling

This commit is contained in:
Daniel Odendahl Jr
2017-05-05 21:37:30 +00:00
parent d8a773958d
commit 13cbd23f2f
54 changed files with 120 additions and 156 deletions
+2 -2
View File
@@ -29,11 +29,11 @@ module.exports = class GoogleCommand extends Command {
.get(`https://www.google.com/search?q=${query}`);
const $ = cheerio.load(text);
let href = $('.r').first().find('a').first().attr('href');
if(!href) throw new Error('No Results');
if(!href) throw new Error('No Results.');
href = querystring.parse(href.replace('/url?', ''));
return message.edit(href.q);
} catch(err) {
return message.edit('No Results Found.');
return message.edit('An Error Occurred: No Results.');
}
}
};