test-errors-actor.js (1427B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 const protocol = require("resource://devtools/shared/protocol.js"); 7 8 const testErrorsSpec = protocol.generateActorSpec({ 9 typeName: "testErrors", 10 11 methods: { 12 throwsComponentsException: { 13 request: {}, 14 response: {}, 15 }, 16 throwsException: { 17 request: {}, 18 response: {}, 19 }, 20 throwsJSError: { 21 request: {}, 22 response: {}, 23 }, 24 throwsString: { 25 request: {}, 26 response: {}, 27 }, 28 throwsObject: { 29 request: {}, 30 response: {}, 31 }, 32 }, 33 }); 34 35 class TestErrorsActor extends protocol.Actor { 36 constructor(conn) { 37 super(conn, testErrorsSpec); 38 } 39 40 throwsComponentsException() { 41 throw Components.Exception("", Cr.NS_ERROR_NOT_IMPLEMENTED); 42 } 43 44 throwsException() { 45 return this.a.b.c; 46 } 47 48 throwsJSError() { 49 throw new Error("JSError"); 50 } 51 52 throwsString() { 53 // eslint-disable-next-line no-throw-literal 54 throw "ErrorString"; 55 } 56 57 throwsObject() { 58 // eslint-disable-next-line no-throw-literal 59 throw { 60 error: "foo", 61 }; 62 } 63 } 64 exports.TestErrorsActor = TestErrorsActor; 65 66 class TestErrorsFront extends protocol.FrontClassWithSpec(testErrorsSpec) { 67 constructor(client) { 68 super(client); 69 this.formAttributeName = "testErrorsActor"; 70 } 71 } 72 protocol.registerFront(TestErrorsFront);