source: gs3-extensions/seaweed-debug/trunk/src/Error.js@ 25160

Last change on this file since 25160 was 25160, checked in by sjm84, 12 years ago

Initial cut at a version of seaweed for debugging purposes. Check it out live into the web/ext folder

File size: 1.4 KB
Line 
1/*
2 * file: Error.js
3 *
4 * @BEGINLICENSE
5 * Copyright 2010 Brook Novak (email : [email protected])
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 * @ENDLICENSE
18 */
19bootstrap.provides("Error");
20
21// @DEBUG ON
22var _ErrorCode = {
23
24 // @REPLACE _ErrorCode.BAD_ARGS 1
25 BAD_ARGS : 1
26
27
28};
29// @DEBUG OFF
30
31var _ErrorMessages = { // TODO: multi-language support ?
32
33 '1' : "Bad arguments"
34
35};
36
37/**
38 * Raises an error and ends execution (throws error)
39 *
40 * @param {Number, String} arg If string the error raises with contain the message
41 * otherwise if number then the error will contain
42 * the message for the error code
43 */
44function _error(arg) {
45 throw new Error(typeof arg == "number" ? _ErrorMessages[arg] : arg);
46}
47
48
Note: See TracBrowser for help on using the repository browser.