[Bug] Throw errors instead of logging to console in appendXp() / subtractXp()
Closed this issue · 2 comments
dev-737 commented
Package version
1.1.16
Issue description
When I try using appendXp()
or subtractXp()
and the XP value is below 0, it logs a message to the console saying:
Failed to subtract XP: ValidationError: level: Cast to Number failed for value "NaN" (type number) at path "level"
It would be better if it threw an Error instead, so it would be easier to use it in cases like these, where you have to inform the user about it by catching it using a try-catch block.
Myst82015 commented
I'll take a look at it.
I'll also ask MrAugu for his opinion.
Myst82015 commented
Hey there ✋
I've changed the methods so they now throw a proper TypeError rather then logging something into the console.
The changes can be found in the branch below:
https://github.com/MrAugu/discord-xp/tree/role-rewards