algotrader
Version:
Algorithmically trade stocks and options using Robinhood, Yahoo Finance, and more.
28 lines (24 loc) • 728 B
JavaScript
class LibraryError extends Error {
/**
* @author Torrey Leonard <https://github.com/Ladinn>
* @param message
*/
constructor(message) {
if (message.indexOf("{") === 0) {
let json = JSON.parse(message);
let keys = Object.keys(json);
if (keys.length === 1) message = JSON.stringify(json[keys[0]], null, 2);
else message = JSON.stringify(json, null, 2);
}
super(message + "\n\n> Please report all unexpected errors on GitHub: https://git.io/vpYYL\n");
}
/**
* @author Torrey Leonard <https://github.com/Ladinn>
* @returns {string}
*/
toString() {
let line = "\u2501".repeat(process.stdout.columns - 5);
return line + "\n" + this.message + "\b\n" + line;
}
}
module.exports = LibraryError;