{"record":{"id":"23ce54ab72f7ee77","repo":"nwjs/nw.js","slug":"expecting-set-string-optional-string-optional-bo","errorCode":null,"errorMessage":"Expecting set(string, optional string, optional boolean) or set(ClipboardData[]) or set(ClipboardData).","messagePattern":"Expecting set\\(string, optional string, optional boolean\\) or set\\(ClipboardData\\[\\]\\) or set\\(ClipboardData\\)\\.","errorType":"validation","errorClass":"TypeException","httpStatus":null,"severity":"error","filePath":"src/resources/api_nw_clipboard.js","lineNumber":64,"sourceCode":"    return nwClipboardBinding.getListSync([type])[0].data;\n  }\n  throw new TypeException('Expecting get(string, optional boolean) or get(ClipboardData[]) or get(ClipboardData).');\n};\nNWClipboard.prototype.set = function (content, type, raw) {\n  var toString = $Object.prototype.toString;\n  // set(ClipboardData[])\n  if (arguments.length === 1 && toString.apply(content) === '[object Array]') {\n    return nwClipboardBinding.setListSync(content);\n  }\n  // set(DOMString, DOMString, boolean)\n  if (toString.apply(content) === '[object String]') {\n    return nwClipboardBinding.setListSync([{type: type || 'text', raw: !!raw, data: content}]);\n  }\n  // set(ClipboardData)\n  if (arguments.length === 1) {\n    return nwClipboardBinding.setListSync([content]);\n  }\n  throw new TypeException('Expecting set(string, optional string, optional boolean) or set(ClipboardData[]) or set(ClipboardData).');\n};\nNWClipboard.prototype.clear = function () {\n  return nwClipboardBinding.clearSync();\n};\nNWClipboard.prototype.readAvailableTypes = function() {\n  return nwClipboardBinding.readAvailableTypes();\n};\n\nnwClipboardBinding['get'] = NWClipboard['get'];\n\n","sourceCodeStart":46,"sourceCodeEnd":75,"githubUrl":"https://github.com/nwjs/nw.js/blob/e15da848e9e08e6e467532dae78995c6ad2f55ee/src/resources/api_nw_clipboard.js#L46-L75","documentation":"Thrown by nw.Clipboard.set when arguments match none of the supported overloads: set(string[, string[, boolean]]), set(ClipboardData[]), or set(ClipboardData). The dispatcher checks Array tag, String tag, and argument count, then throws if nothing matches.","triggerScenarios":"Calling `nw.Clipboard.set()` with no args, `nw.Clipboard.set(null)`, or `nw.Clipboard.set(123)`.","commonSituations":"Passing a number or object as content without wrapping it as a ClipboardData; forgetting the content argument when specifying only a type.","solutions":["Set text: `nw.Clipboard.set('hello', 'text')` or just `nw.Clipboard.set('hello')`.","Set multiple entries: `nw.Clipboard.set([{ type: 'text', data: 'hi' }])`.","Set a single ClipboardData: `nw.Clipboard.set({ type: 'text', data: 'hi' })`."],"exampleFix":"// before\nnw.Clipboard.set();\n// after\nnw.Clipboard.set('hello', 'text');","handlingStrategy":"validation","validationCode":"function safeSet(content, type) {\n  if (typeof content !== 'string' && !Array.isArray(content) && (typeof content !== 'object' || content === null))\n    throw new TypeError('Invalid clipboard content');\n  return nw.Clipboard.set(content, type);\n}","typeGuard":"function isClipboardData(v) { return v && typeof v === 'object' && typeof v.type === 'string'; }","tryCatchPattern":"try { nw.Clipboard.set(content, type); } catch (e) { if (/Expecting set/.test(e.message)) nw.Clipboard.set(String(content), 'text'); else throw e; }","preventionTips":["Coerce content to a string before calling set for text.","Use ClipboardData objects for non-text types."],"tags":["clipboard","overload","type-check","nwjs"],"backgroundTag":null,"analyzedSha":"e15da848e9e08e6e467532dae78995c6ad2f55ee","analyzedAt":"2026-08-13T04:15:35.452Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}