{"record":{"id":"39534a82e5f48fef","repo":"dani-garcia/vaultwarden","slug":"msg","errorCode":null,"errorMessage":"msg","messagePattern":"msg","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/static/scripts/datatables.js","lineNumber":3990,"sourceCode":"            (ctx ? 'table id=' + ctx.tableId + ' - ' : '') +\n            msg;\n    if (tn) {\n        msg +=\n            '. For more information about this error, please see ' +\n                'https://datatables.net/tn/' +\n                tn;\n    }\n    {\n        // Backwards compatibility pre 1.10\n        var type = ext.sErrMode || ext.errMode;\n        if (ctx) {\n            callbackFire(ctx, null, 'dt-error', [ctx, tn, msg], true);\n        }\n        if (type == 'alert') {\n            alert(msg);\n        }\n        else if (type == 'throw') {\n            throw new Error(msg);\n        }\n        else if (typeof type == 'function') {\n            type(ctx, tn, msg);\n        }\n    }\n}\n/**\n * See if a property is defined on one object, if so assign it to the other\n * object\n *\n * @param ret target object\n * @param src source object\n * @param name property\n * @param mappedName name to map too - optional, name used if not given\n */\nfunction map(ret, src, name, mappedName) {\n    if (Array.isArray(name)) {\n        for (let i = 0; i < name.length; i++) {","sourceCodeStart":3972,"sourceCodeEnd":4008,"githubUrl":"https://github.com/dani-garcia/vaultwarden/blob/6729e835218edb29b644a99f65a3b76cde9a341d/src/static/scripts/datatables.js#L3972-L4008","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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)."],"exampleFix":"// before\n$('#table').DataTable({\n  ajax: '/api/rows',\n  errMode: 'throw', // hard crash on any internal error\n  columns: [{ data: 'userName' }] // payload actually has `user_name`\n});\n// after\n$('#table').DataTable({\n  ajax: '/api/rows',\n  errMode: function (ctx, tn, msg) { console.error('DataTables:', msg); },\n  columns: [{ data: 'user_name' }]\n});","handlingStrategy":"try-catch","validationCode":"function validatePayloadForTable(payload, columns) {\n  if (!Array.isArray(payload.data))\n    throw new Error('Ajax source must return { data: [...] }');\n  for (const col of columns) {\n    if (typeof col.data === 'string' && payload.data.length &&\n        !(col.data in payload.data[0])) {\n      console.warn('Column field missing in payload:', col.data);\n    }\n  }\n}\n// call before table.ajax.reload() or initialisation; also check errMode:\n// if ($.fn.DataTable.ext.errMode === 'throw') { /* wrap usage in try/catch */ }","typeGuard":"function isErrMode(mode) {\n  return mode === 'alert' || mode === 'throw' ||\n    mode === 'console' || typeof mode === 'function';\n}\nfunction throwsOnError(tableInit) {\n  return tableInit && tableInit.errMode === 'throw';\n}","tryCatchPattern":"try {\n  const table = $('#table').DataTable({ errMode: 'throw', ajax: '/api/rows', columns });\n  table.ajax.reload(null, false);\n} catch (e) {\n  if (String(e.message).startsWith('DataTables warning')) {\n    // DataTables internal error (unknown parameter, invalid JSON, reinit...)\n    console.error('DataTables:', e.message);\n    showErrorToast(e.message);\n  } else { throw e; }\n}","preventionTips":["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."],"tags":["datatables","configuration","error-handling","ajax"],"backgroundTag":"datatables-errmode-throw","analyzedSha":"6729e835218edb29b644a99f65a3b76cde9a341d","analyzedAt":"2026-09-02T22:55:15.880Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}