bradymholt / cRonstrue

JavaScript library that translates Cron expressions into human readable descriptions
http://bradymholt.github.io/cRonstrue/
MIT License
1.28k stars 168 forks source link

Suggestion: Descriptive error message #309

Closed LordKriegan closed 9 months ago

LordKriegan commented 9 months ago

Hi! I have a mongoose schema that I had added a virtual to translate a cron expression into a human-readable string using your package. Initially, I had just set virtuals to true at the schema level. That did lead to an error in one method where I was excluding my cron interval field (which the virtual translates from). It took me a good hour to figure that out however, as the error message you output only says "Expression is empty" May I suggest that you should add some extra verbage on where the error is coming from and why? For example: "cRonstrue Error: Expression passed to <method> is empty" or something to that effect. That way at least we know where the error is coming from.

bradymholt commented 9 months ago

Are you suggesting that the error message itself contain the name of the package "cRonstrue"? If so, I'd rather not hardcode the package name in the error messages as the package name might change at some point in the future. It sounds like you may be able to add some additional logging info in your system to pinpoint the source of an error.

LordKriegan commented 9 months ago

dont need to hardcode the package name. im assuming you have a config file somewhere or you can import your package.json and pull the name of the package from there. Don't even need the package name; that was just an example. Im just saying that "Expression is empty" was a frustratingly vague error message that provided no context as to where it was coming from.