Warnings
Some problems aren't worth stopping for, such as a solver reaching its iteration limit and returning what it found so far. Nerdamer records these as warnings instead of throwing an error. By default it records them silently.
A warning doesn't mean the result is wrong, and the absence of one doesn't mean it is right. Invalid input and failed calculations still throw errors.
Reading warnings
import nerdamer from 'nerdamer';
const warnings = nerdamer.getWarnings(); // [{ code, message }, ...]
nerdamer.clearWarnings();
Each warning has a code, which stays the same between versions so your code can check it, and a message for people.
Getting them as they happen
nerdamer.setWarningHandler(warning => {
// Show warning.message in your own UI, or check warning.code.
});
nerdamer.setWarningHandler(); // stop
To print them to the console instead, call nerdamer.setConsoleWarnings(true). It's off by default, and does nothing where there is no console.
If your handler throws, the error reaches the code that triggered the warning, so keep handlers from throwing.
The warnings
| Code | When |
|---|---|
api.deprecatedDelete | You called setConstant(name, 'delete') or setVar(name, 'delete'). The value is still removed. |
api.deprecatedFunction | You called a function by its Nerdamer 1.x name, such as IF instead of if or solveEquations instead of solveeqs. The function still runs; the message names the one to use. |
defint.depthLimit | A numeric definite integral ran out of subdivisions before reaching the accuracy it aimed for. |
defint.singularity | A definite integral meets a point where the function isn't finite, as in defint(1/x,x,0,1). The integral stays unevaluated. |
solve.iterationLimit | A solver reached its iteration limit and returned what it had. |
solve.generationLimit | SolutionSet.generate() stopped at 1,000 members. The result has partial = true, and members in the requested range may be missing. |
tex.periodicVariable | A periodic solution's _n was written in TeX with another letter, because the expression already uses the one set by TEX_PERIODIC_VAR. |
A slow or large calculation doesn't produce a warning by itself.
Shared by the whole app
The warning list and the handler apply to your whole app, not to one expression or one caller. Calculations running side by side share them.
