12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- 'use strict';
- /**
- Part of Zombie Navigator
- Copyright © 2015 Zombie Navigator Developers
-
- @file
- @license AGPL-3.0+
- */
- /*
- Zombie script example (= unprivileged)
- Do NOT require () this script from the addon code.
-
- A basic example of a Zombie script
- */
- const {zombie, console} = require('zombie/zombie');
- const {openWindow, closeAll} = require('zombie/webbrowser');
- const {run} = require('zombie/async');
- try {
- run(function* () {
- try {
- yield new Promise(function (resolve, reject) {
- reject(new Error('Error!'));
- });
- } catch (e) {
- console.log('Error inside coroutine:', e);
- closeAll();
- let result = yield new Promise(function (resolve, reject) {
- resolve(42);
- });
- console.log('result:', result);
-
- throw e;
- }
- })
- .catch(function (e) {
- console.log('Error via promise:', e + '');
- closeAll();
- });
- } catch (e) {
- console.log('Error:', e + '');
- closeAll();
- }
- // vim: ts=4 noet ai
|