{"record":{"id":"c60556480a349fbc","repo":"nwjs/nw.js","slug":"invalid-option-c60556","errorCode":null,"errorMessage":"Invalid option","messagePattern":"Invalid option","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"src/api/tray/tray.js","lineNumber":25,"sourceCode":"//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell co\n// pies of the Software, and to permit persons to whom the Software is furnished\n//  to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in al\n// l copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IM\n// PLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNES\n// S FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS\n//  OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WH\n// ETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n//  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nvar v8_util = process.binding('v8_util');\n\nfunction Tray(option) {\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 = nw.getAbsolutePath(option.icon);\n  }\n\n  if (option.hasOwnProperty('alticon')) {\n    option.shadowAlticon = String(option.alticon);\n    option.alticon = nw.getAbsolutePath(option.alticon);\n  }","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/nwjs/nw.js/blob/e15da848e9e08e6e467532dae78995c6ad2f55ee/src/api/tray/tray.js#L7-L43","documentation":"Thrown by the nw.Tray constructor when the option argument is not an object (typeof check). Tray requires an options object because it must read at least 'title' or 'icon' from it. Primitives, null in some engines, and undefined all fail this guard.","triggerScenarios":"Calling `new nw.Tray()`, `new nw.Tray(null)`, `new nw.Tray('My Tray')`, or `new nw.Tray(42)`.","commonSituations":"Forgetting to pass options; passing a string title directly as in older tray APIs; passing a variable that was conditionally assigned and ended up undefined.","solutions":["Pass an options object: `new nw.Tray({ title: 'My App' })`.","Default the argument: `new nw.Tray(options || { title: 'App' })`.","Add a typeof guard before construction to surface a clearer upstream error."],"exampleFix":"// before\nconst tray = new nw.Tray(appTitle);\n// after\nconst tray = new nw.Tray({ title: appTitle });","handlingStrategy":"validation","validationCode":"if (typeof option !== 'object' || option === null) option = {};","typeGuard":"function isTrayOption(o) { return o && typeof o === 'object' && (o.hasOwnProperty('title') || o.hasOwnProperty('icon')); }","tryCatchPattern":"try { new nw.Tray(opt); } catch (e) { if (/Invalid option/.test(e.message)) opt = { title: 'App' }; else throw e; }","preventionTips":["Always construct the options object explicitly before passing it.","Default the argument: opt = opt || {}."],"tags":["tray","constructor","type-check","nwjs"],"backgroundTag":null,"analyzedSha":"e15da848e9e08e6e467532dae78995c6ad2f55ee","analyzedAt":"2026-08-13T04:15:35.452Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}