Errors

Tab completely redesigned from version 3.2.0 (beta) onwards. In 3.1.2, it only lists compilation errors and duplicate identifiers.

The Errors tab analyzes the whole database and lists the errors and warnings in its code: fields, triggers, view columns, print reports, global code and the "After Open" trigger. The analysis is done by an analyzer transcribed from Ninox's own: what it reports matches what Ninox would say. Each line takes you straight to the code involved.

The tab is reserved for administrators. It only shows its icon, a warning triangle; its name appears on hover, and a red badge gives the number of diagnostics displayed.

The summary and the filters

Filters of the Errors tab

The header gives the summary: "No error", "3 error(s)", "3 error(s), 12 warning(s)", "36 warning(s)"…

The Filters button opens the Displayed diagnostics panel: one switch per type of diagnostic, arranged in two groups, Errors and Warnings. Each line gives the number of diagnostics of that type in the database — even when the type is hidden: you see what you hide as well as what you show. When types are hidden, the button reminds you ("2 type(s) hidden"); Show all brings them back. The filters are remembered by the browser and apply to all databases.

What is reported

Errors prevent the code from working:

FilterWhat is reported
Compilation errorsCode that Ninox rejects: the formula does not run.
Duplicate IDsSeveral fields of the same table share the same internal identifier (for example an input field and a visual element): references become ambiguous.
Analyzer errorsFaults that Ninext's analyzer finds and that Ninox did not report.
Embedded content errorsA JavaScript syntax error in a native block #{ … }#.

Warnings point out code that works, but probably not the way you think:

FilterWhat is reported
AnalyzerNinox's warnings, and malformed NativeJS annotations (unknown type, table not found).
Server contextCode that has no effect where it runs: a user-interface function such as alert() or openRecord(), or a native block #{ … }#, placed in a table trigger (after create, after update) or in a do as server. On the server, they are silently ignored.
Stale errorsErrors that Ninox still displays although the formula is sound (see below).
Unresolved referencesReading a reference field whose target table no longer exists (deleted table, missing external database): it yields "void", and any dot traversal breaks.
Embedded contentA typed JavaScript block that returns nothing, on all of its paths or on some of them; an asynchronous block that never calls callback; unbalanced HTML passed to html() (a tag never closed, an orphan closing tag); CSS with unbalanced braces, or whose rules the browser will discard.
Dead code inside scriptsVariables declared with var or let, then never read.
Unused global functionsGlobal functions that nothing in the database calls.
Unused formulasFormulas that no code references.

Unused functions and formulas are only candidates for deletion: a call built dynamically or made from JavaScript escapes the analysis, and a formula displayed in a form or a view remains useful even if no code reads it. Check before deleting.

Reading a line

Diagnostics in the Errors tab

Diagnostics are grouped by family. Each family's title carries a badge that gives their number: red for errors, orange for warnings. When there are several families, they are collapsed, and clicking a title expands its family; a single family is displayed expanded.

Families bear the name of their filter, except these:

FilterFamily in the list
Analyzer errorsAdditional errors from the Ninext analyzer
AnalyzerAnalyzer warnings
Server contextCode outside its execution context
Stale errorsStale errors (the formula is sound)
Embedded content errors and Embedded contentA single family, Embedded JS / HTML / CSS, which carries up to two badges: one for its errors, one for its warnings.

Each line gives:

  • in italics, the message — gray for an error, amber for a warning — followed by the code excerpt involved; when two types do not match, a sentence says which ones;
  • the item concerned, presented as in Fields & Formulas: type icon, dependency badge, "Fx", breadcrumb.

Hovering the bold part of the breadcrumb (the formula, the trigger or the global function) shows the code, with the faults underlined.

Going to the code

Click the bold part of the breadcrumb: Ninext opens the editor at the right place. For the global code, the diagnostic is attached to the function that contains it — "Global functions › functionName" — and the global code editor opens on it. The "After Open" trigger opens the same way.

The red button that appears on hover, on the right of the line, in "Edit mode", selects the field on its form for a line that concerns a field, and opens the code editor for the other lines.

Below, in the demo database, a click on the bold part of a line that concerns a field's formula: Ninext opens a record of the table, the field's dialog, then the large formula editor, where the passage at fault is underlined; hovering over it gives the message. The other parts of the breadcrumb open their own level: a click on the field's name opens the record and the field's dialog, without the editor.

From the Errors tab, a click on the bold part opens the editor of the formula at fault, faulty passage underlined

An analysis that runs in the background

The analysis works in small slices, handing control back to the browser: even on a large database, nothing freezes. It restarts by itself after every schema change. There is no progress indicator: the previous list stays displayed until the new one replaces it.

Stale errors

Sometimes Ninox compiles a formula field while the schema is being reloaded, before it is complete, and then never compiles it again: the field shows errors for the whole session, although its formula is correct. Ninext recompiles the formula on its side; if the errors do not appear there, it files them under Stale errors.

Fix: reload the database, or save any change to the schema.

As you type, in Ninox's editors

Errors and warnings are also underlined as you type in Ninox's script editors (large formula editor, panel of a field or of a table):

  • a red squiggle for an error, an amber dotted line for a warning;
  • when you hover the underlined passage, a tooltip explains it, and says which types do not match;
  • underlining only happens when Ninext knows for certain in which table the code runs;
  • the autocompletion list has priority: no tooltip opens while it is displayed.

Selecting a word highlights its other occurrences — in Ninox's editors, in the Console and in Ninext's code blocks. When you hover the editor, two buttons appear in the top right corner: Format code and Debug in the Console (see Console).

Residual columns in table views

A compilation error can come from a table view column that still uses a deleted field. Ninox reports nothing, since the field has simply been removed from the schema: it is a residual reference, left behind in the view's column configuration.

To fix it:

  1. Click Formula, in bold at the end of the breadcrumb ("Table › View › … › Formula").
  2. Ninext opens the view, the column editor, then the editor of its formula.
  3. Click OK in the formula editor, then in the column editor.

When saved, Ninox refreshes the view configuration and removes the references to non-existing fields. The error disappears from Ninext.