Skip to content

Commit

Permalink
Error handling for scripting.executeScript() (mdn#22279)
Browse files Browse the repository at this point in the history
* Error handling for scripting.executeScript()

* Corrections

* Feedback suggestion

Co-authored-by: Rob Wu <[email protected]>

Co-authored-by: Rob Wu <[email protected]>
  • Loading branch information
rebloor and Rob--W committed Nov 20, 2022
1 parent f12a6b6 commit d3dc224
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ Each `InjectionResult` object has these properties:
- `result` {{optional_inline}}
- : `any`. The result of the script execution.
- `error` {{optional_inline}}
- : `object`. When the injection fails, details of the failure errors.
- `message`
- : `string`. A message explaining why the injection failed.
- : `any`. If an error occurs, contains the value the script threw or rejected with. Typically this is an error object with a message property but it could be any value (including primitives and undefined).

The result of the script is the last evaluated statement, which is similar to the results seen if you executed the script in the [Web Console](https://firefox-source-docs.mozilla.org/devtools-user/web_console/index.html) (not any `console.log()` output). For example, consider a script like this:

Expand Down
2 changes: 2 additions & 0 deletions files/en-us/mozilla/firefox/releases/107/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ No notable changes

### Other

- The `error` property returned when an error occurs in {{WebExtAPIRef("scripting.executeScript")}} now represents any value the script throws or rejects with, instead of being just an object with a message property {{bug(1740608)}}.

## Older versions

{{Firefox_for_developers(106)}}

0 comments on commit d3dc224

Please sign in to comment.