jiggzson / nerdamer

a symbolic math expression evaluator for javascript
http://www.nerdamer.com
MIT License
514 stars 82 forks source link

Review on err and warn #353

Open Happypig375 opened 6 years ago

Happypig375 commented 6 years ago
  1. Console output Maybe err and warn should output an error and warning to the JavaScript console respectively. The code also should not throw a TypeError or something alike if a console is not present. Like this:

    if(console) console.error(msg);
    if(console) console.warn(msg);
  2. Document err, warn and related APIs warn is currently unused and undocumented. Document this along with getWarnings()

  3. 1st use case for warn I can think of a first use case right now: Passing 'delete' into setConstant and setVar to delete the constant and the variable should be considered bad practice and should be deprecated. A warning can be inserted there to alert the user.

  4. 2nd use case for warn Experimental APIs. Warn when useAlgebraDiv or something alike is used.

  5. 3rd use case for warn Really big numbers. Things like 10^10^100 will cause a really, really long hang. Consider warning these.

More warnings should be added in the future.

jiggzson commented 6 years ago

I'd like to add to this issue and say that Errors need to be cleaned up in general. Generic errors need to be replaced with specific errors.

Happypig375 commented 6 years ago

Ah, and also document the nerdamer-thrown errors (nersamer.getCore().exceptions.ParseError etc)