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

Wed, 31 Dec 2014 07:53:36 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:53:36 +0100
branch
TOR_BUG_3246
changeset 5
4ab42b5ab56c
permissions
-rw-r--r--

Correct small whitespace inconsistency, lost while renaming variables.

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

mercurial