GM_getResourceText throws unexpected and unhelpful error on missing resource name #1796

Closed
BrockA opened this Issue Sep 1, 2013 · 2 comments

Projects

None yet

3 participants

@BrockA
BrockA commented Sep 1, 2013

Consider:

// ==UserScript==
// @name        _GM_getResourceText error
// @grant       GM_getResourceText
// ==/UserScript==

var github_style_CSS = GM_getResourceText ("MissingResourceName");

This should throw the error defined in the appropriate greasemonkey.properties file. EG, "No resource with name: MissingResourceName".

Instead it throws:

Error: this.stringBundle is undefined
Source File: file:/// .../gm_scripts/_GM_getResourceText_error/_GM_getResourceText_error.user.js
Line: 81

This looks to be an error in miscapis.js at lines 13 and 81, but I haven't updated my source or tried to fix it yet.

@janekptacijarabaci janekptacijarabaci pushed a commit to janekptacijarabaci/greasemonkey that referenced this issue Sep 1, 2013
janekptacijarabaci GM_getResourceText throws unexpected and unhelpful error on missing r…
…esource name

Ad greasemonkey#1796
7abc7a6
@janekptacijarabaci

The problem with the line number (and the file name) - for example:

From:

  throw new Error(
        this.stringBundle.GetStringFromName('error.missingResource')
        .replace('%1', name)
  );

To:

  try {
    null.length;
  }
  catch(e) {
    e.message = this.stringBundle.GetStringFromName('error.missingResource').replace('%1', name);
    GM_util.logError(e.message, false, e.fileName, e.lineNumber + 4);
    throw new Error(e.message, null, 0);
  }

Result:
test

And preferably: The change throw an exception in all files...

@arantius
Collaborator

Merged.

@arantius arantius closed this Sep 27, 2013
@sizzlemctwizzle sizzlemctwizzle pushed a commit to sizzlemctwizzle/greasemonkey that referenced this issue Nov 5, 2013
janekptacijarabaci GM_getResourceText throws unexpected and unhelpful error on missing r…
…esource name

Ad greasemonkey#1796
2b5fe2e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment