services/sync/tps/extensions/mozmill/resource/modules/errors.js

branch
TOR_BUG_3246
changeset 5
4ab42b5ab56c
equal deleted inserted replaced
-1:000000000000 0:3dc9ca4d952d
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, you can obtain one at http://mozilla.org/MPL/2.0/. */
4
5 var EXPORTED_SYMBOLS = ['BaseError',
6 'ApplicationQuitError',
7 'AssertionError',
8 'TimeoutError'];
9
10
11 /**
12 * Creates a new instance of a base error
13 *
14 * @class Represents the base for custom errors
15 * @param {string} [aMessage=Error().message]
16 * The error message to show
17 * @param {string} [aFileName=Error().fileName]
18 * The file name where the error has been raised
19 * @param {string} [aLineNumber=Error().lineNumber]
20 * The line number of the file where the error has been raised
21 * @param {string} [aFunctionName=undefined]
22 * The function name in which the error has been raised
23 */
24 function BaseError(aMessage, aFileName, aLineNumber, aFunctionName) {
25 this.name = this.constructor.name;
26
27 var err = new Error();
28 if (err.stack) {
29 this.stack = err.stack;
30 }
31
32 this.message = aMessage || err.message;
33 this.fileName = aFileName || err.fileName;
34 this.lineNumber = aLineNumber || err.lineNumber;
35 this.functionName = aFunctionName;
36 }
37
38
39 /**
40 * Creates a new instance of an application quit error used by Mozmill to
41 * indicate that the application is going to shutdown
42 *
43 * @class Represents an error object thrown when the application is going to shutdown
44 * @param {string} [aMessage=Error().message]
45 * The error message to show
46 * @param {string} [aFileName=Error().fileName]
47 * The file name where the error has been raised
48 * @param {string} [aLineNumber=Error().lineNumber]
49 * The line number of the file where the error has been raised
50 * @param {string} [aFunctionName=undefined]
51 * The function name in which the error has been raised
52 */
53 function ApplicationQuitError(aMessage, aFileName, aLineNumber, aFunctionName) {
54 BaseError.apply(this, arguments);
55 }
56
57 ApplicationQuitError.prototype = Object.create(BaseError.prototype, {
58 constructor : { value : ApplicationQuitError }
59 });
60
61
62 /**
63 * Creates a new instance of an assertion error
64 *
65 * @class Represents an error object thrown by failing assertions
66 * @param {string} [aMessage=Error().message]
67 * The error message to show
68 * @param {string} [aFileName=Error().fileName]
69 * The file name where the error has been raised
70 * @param {string} [aLineNumber=Error().lineNumber]
71 * The line number of the file where the error has been raised
72 * @param {string} [aFunctionName=undefined]
73 * The function name in which the error has been raised
74 */
75 function AssertionError(aMessage, aFileName, aLineNumber, aFunctionName) {
76 BaseError.apply(this, arguments);
77 }
78
79 AssertionError.prototype = Object.create(BaseError.prototype, {
80 constructor : { value : AssertionError }
81 });
82
83 /**
84 * Creates a new instance of a timeout error
85 *
86 * @class Represents an error object thrown by failing assertions
87 * @param {string} [aMessage=Error().message]
88 * The error message to show
89 * @param {string} [aFileName=Error().fileName]
90 * The file name where the error has been raised
91 * @param {string} [aLineNumber=Error().lineNumber]
92 * The line number of the file where the error has been raised
93 * @param {string} [aFunctionName=undefined]
94 * The function name in which the error has been raised
95 */
96 function TimeoutError(aMessage, aFileName, aLineNumber, aFunctionName) {
97 AssertionError.apply(this, arguments);
98 }
99
100 TimeoutError.prototype = Object.create(AssertionError.prototype, {
101 constructor : { value : TimeoutError }
102 });

mercurial