dani-garcia/vaultwarden · error · Error
msg
Error message
msg
What it means
This throw comes from DataTables' internal error reporter (the _fnLog/errMode mechanism). DataTables raises internal errors such as 'Requested unknown parameter', 'Invalid JSON response', 'Cannot reinitialise DataTable', or 'Non-table node initialisation'; depending on the errMode setting it logs to console, alerts, fires the 'dt-error' event, throws an Error, or hands the message to a custom function. When errMode is 'throw', those internal warnings become hard exceptions that stop execution.
Source
Thrown at src/static/scripts/datatables.js:3990
(ctx ? 'table id=' + ctx.tableId + ' - ' : '') +
msg;
if (tn) {
msg +=
'. For more information about this error, please see ' +
'https://datatables.net/tn/' +
tn;
}
{
// Backwards compatibility pre 1.10
var type = ext.sErrMode || ext.errMode;
if (ctx) {
callbackFire(ctx, null, 'dt-error', [ctx, tn, msg], true);
}
if (type == 'alert') {
alert(msg);
}
else if (type == 'throw') {
throw new Error(msg);
}
else if (typeof type == 'function') {
type(ctx, tn, msg);
}
}
}
/**
* See if a property is defined on one object, if so assign it to the other
* object
*
* @param ret target object
* @param src source object
* @param name property
* @param mappedName name to map too - optional, name used if not given
*/
function map(ret, src, name, mappedName) {
if (Array.isArray(name)) {
for (let i = 0; i < name.length; i++) {View on GitHub (pinned to 6729e83521)
Solutions
- Fix the underlying message shown in the error: align columns.data with the actual JSON payload fields, or repair the Ajax endpoint so it returns valid JSON.
- If you only want to observe errors without crashing, set errMode: 'alert' (default) or 'console', or register $.fn.DataTable.ext.errMode = function(ctx, tn, msg) { ... } to handle messages yourself.
- Wrap table construction and row processing in try/catch when running in throw mode so one bad row does not abort the whole page.
- Listen for the 'dt-error' event (callbackFire emits it before throwing) to log failures centrally.
- Validate the Ajax response shape before initialising or reloading the table (check data is an array, fields exist).
Example fix
// before
$('#table').DataTable({
ajax: '/api/rows',
errMode: 'throw', // hard crash on any internal error
columns: [{ data: 'userName' }] // payload actually has `user_name`
});
// after
$('#table').DataTable({
ajax: '/api/rows',
errMode: function (ctx, tn, msg) { console.error('DataTables:', msg); },
columns: [{ data: 'user_name' }]
}); Defensive patterns
Strategy: try-catch
Validate before calling
function validatePayloadForTable(payload, columns) {
if (!Array.isArray(payload.data))
throw new Error('Ajax source must return { data: [...] }');
for (const col of columns) {
if (typeof col.data === 'string' && payload.data.length &&
!(col.data in payload.data[0])) {
console.warn('Column field missing in payload:', col.data);
}
}
}
// call before table.ajax.reload() or initialisation; also check errMode:
// if ($.fn.DataTable.ext.errMode === 'throw') { /* wrap usage in try/catch */ } Type guard
function isErrMode(mode) {
return mode === 'alert' || mode === 'throw' ||
mode === 'console' || typeof mode === 'function';
}
function throwsOnError(tableInit) {
return tableInit && tableInit.errMode === 'throw';
} Try / catch
try {
const table = $('#table').DataTable({ errMode: 'throw', ajax: '/api/rows', columns });
table.ajax.reload(null, false);
} catch (e) {
if (String(e.message).startsWith('DataTables warning')) {
// DataTables internal error (unknown parameter, invalid JSON, reinit...)
console.error('DataTables:', e.message);
showErrorToast(e.message);
} else { throw e; }
} Prevention
- Leave errMode at the default or set it to a custom function rather than 'throw' in user-facing pages.
- Keep columns.data in sync with the server payload; add a payload-shape test against a real API response.
- Ensure Ajax endpoints return application/json with a data array even on failure.
- Guard against double initialisation (check $.fn.DataTable.isDataTable(selector)).
- Subscribe to the 'dt-error' event for centralized logging even when not in throw mode.
When it happens
Trigger: Setting `errMode: 'throw'` (on the instance or via $.fn.DataTable.ext.errMode = 'throw') and then triggering any internal DataTables error — e.g. a column references a data property that is undefined ('Requested unknown parameter'), the Ajax source returns invalid JSON, calling $(...).DataTable() on an already-initialised table, or passing a non-table node to the constructor.
Common situations: Applications that set errMode to 'throw' to catch data problems in production; Ajax endpoints returning HTML error pages instead of JSON after a deploy; renaming server fields without updating columns.data; double-initialising a table whose markup is re-rendered by a framework; custom type callbacks receiving ctx/tn/msg instead of an exception.
Related errors
AI-assisted analysis of dani-garcia/vaultwarden@6729e83521 (2026-09-02).
Data as JSON: /api/errors/39534a82e5f48fef.
Report an issue: GitHub.