{"record":{"id":"e72ca88f63a7d6dc","repo":"nwjs/nw.js","slug":"invalid-option-e72ca8","errorCode":null,"errorMessage":"Invalid option.","messagePattern":"Invalid option\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"src/resources/api_nw_tray.js","lineNumber":26,"sourceCode":"\ntrayEvents.clickEvent = bindingUtil.createCustomEvent(\"NWObjectTrayClick\", false, false);\ntrayEvents.clickEvent.addListener(function(id) {\n  var tray = trayEvents.objs[id];\n  if (!tray)\n    return;\n  var args = Array.prototype.slice.call(arguments, 1);\n  args.unshift('click');\n  tray.emit.apply(tray, args);\n});\n\nfunction Tray(option) {\n  if (!(this instanceof Tray)) {\n    return new Tray(option);\n  }\n  EventEmitter.apply(this);\n\n  if (typeof option != 'object')\n    throw new TypeError('Invalid option.');\n\n  if (!option.hasOwnProperty('title') && !option.hasOwnProperty('icon'))\n    throw new TypeError(\"Must set 'title' or 'icon' field in option\");\n\n  if (!option.hasOwnProperty('title'))\n    option.title = '';\n  else\n    option.title = String(option.title);\n\n  if (option.hasOwnProperty('icon')) {\n    option.shadowIcon = String(option.icon);\n    option.icon = nwNative.getAbsolutePath(option.icon);\n  }\n\n  if (option.hasOwnProperty('alticon')) {\n    option.shadowAlticon = String(option.alticon);\n    option.alticon = nwNative.getAbsolutePath(option.alticon);\n  }","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/nwjs/nw.js/blob/e15da848e9e08e6e467532dae78995c6ad2f55ee/src/resources/api_nw_tray.js#L8-L44","documentation":"Thrown by the Tray constructor when the option argument is not an object (typeof option != 'object'). The constructor requires an options object carrying at least a 'title' or 'icon' field. Note typeof null === 'object' so null bypasses this check and fails later at the hasOwnProperty calls.","triggerScenarios":"new nw.Tray('My App') (string); new nw.Tray() (undefined); new nw.Tray(123) (number); passing a pre-ES5 primitive wrapper.","commonSituations":"Assuming the constructor takes a title string directly; migrating from an API with a simpler signature; passing a variable that was conditionally assigned.","solutions":["Pass an options object: new nw.Tray({ title: 'My App' }) or new nw.Tray({ icon: 'icon.png' }).","Ensure the argument is defined and an object literal before construction."],"exampleFix":"// before\nnew nw.Tray('My App');\n// after\nnew nw.Tray({ title: 'My App' });","handlingStrategy":"type-guard","validationCode":"if (typeof option !== 'object' || option === null) {\n  throw new TypeError('Tray option must be a non-null object');\n}","typeGuard":"function isTrayOption(o) { return typeof o === 'object' && o !== null && !Array.isArray(o); }","tryCatchPattern":null,"preventionTips":["Pass an object literal to new nw.Tray().","Type-check external config before construction.","Remember null is typeof 'object' — exclude it explicitly."],"tags":["nwjs","tray","validation","constructor"],"backgroundTag":null,"analyzedSha":"e15da848e9e08e6e467532dae78995c6ad2f55ee","analyzedAt":"2026-08-13T04:15:35.452Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}