1/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2/* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4 * You can obtain one at http://mozilla.org/MPL/2.0/.
5 *
6 * The origin of this IDL file is
7 * http://dom.spec.whatwg.org/#exception-domexception
8 *
9 * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
10 * liability, trademark and document use rules apply.
11 */
12
13
14// This is the WebIDL version of nsIException.  This is mostly legacy stuff.
15
16// invalid widl
17//interface StackFrame;
18
19[Exposed=(Window,Worker,System)]
20interface mixin ExceptionMembers
21{
22  // The nsresult associated with this exception.
23  readonly attribute unsigned long           result;
24
25  // Filename location.  This is the location that caused the
26  // error, which may or may not be a source file location.
27  // For example, standard language errors would generally have
28  // the same location as their top stack entry.  File
29  // parsers may put the location of the file they were parsing,
30  // etc.
31
32  // null indicates "no data"
33  readonly attribute DOMString               filename;
34  // Valid line numbers begin at '1'. '0' indicates unknown.
35  readonly attribute unsigned long           lineNumber;
36  // Valid column numbers begin at 0.
37  // We don't have an unambiguous indicator for unknown.
38  readonly attribute unsigned long           columnNumber;
39
40  // A stack trace, if available.  nsIStackFrame does not have classinfo so
41  // this was only ever usefully available to chrome JS.
42  [ChromeOnly, Exposed=Window]
43  readonly attribute StackFrame?             location;
44
45  // Arbitary data for the implementation.
46  [Exposed=Window]
47  readonly attribute nsISupports?            data;
48
49  // Formatted exception stack
50  [Replaceable]
51  readonly attribute DOMString               stack;
52};
53
54[NoInterfaceObject, Exposed=(Window,Worker)]
55interface Exception {
56  // The name of the error code (ie, a string repr of |result|).
57  readonly attribute DOMString               name;
58  // A custom message set by the thrower.
59  readonly attribute DOMString               message;
60  // A generic formatter - make it suitable to print, etc.
61  stringifier;
62};
63
64Exception includes ExceptionMembers;
65
66// XXXkhuey this is an 'exception', not an interface, but we don't have any
67// parser or codegen mechanisms for dealing with exceptions.
68[ExceptionClass,
69 Exposed=(Window, Worker,System),
70 Constructor(optional DOMString message = "", optional DOMString name)]
71interface DOMException {
72  // The name of the error code (ie, a string repr of |result|).
73  readonly attribute DOMString               name;
74  // A custom message set by the thrower.
75  readonly attribute DOMString               message;
76  readonly attribute unsigned short code;
77
78  const unsigned short INDEX_SIZE_ERR = 1;
79  const unsigned short DOMSTRING_SIZE_ERR = 2; // historical
80  const unsigned short HIERARCHY_REQUEST_ERR = 3;
81  const unsigned short WRONG_DOCUMENT_ERR = 4;
82  const unsigned short INVALID_CHARACTER_ERR = 5;
83  const unsigned short NO_DATA_ALLOWED_ERR = 6; // historical
84  const unsigned short NO_MODIFICATION_ALLOWED_ERR = 7;
85  const unsigned short NOT_FOUND_ERR = 8;
86  const unsigned short NOT_SUPPORTED_ERR = 9;
87  const unsigned short INUSE_ATTRIBUTE_ERR = 10; // historical
88  const unsigned short INVALID_STATE_ERR = 11;
89  const unsigned short SYNTAX_ERR = 12;
90  const unsigned short INVALID_MODIFICATION_ERR = 13;
91  const unsigned short NAMESPACE_ERR = 14;
92  const unsigned short INVALID_ACCESS_ERR = 15;
93  const unsigned short VALIDATION_ERR = 16; // historical
94  const unsigned short TYPE_MISMATCH_ERR = 17; // historical; use JavaScript's TypeError instead
95  const unsigned short SECURITY_ERR = 18;
96  const unsigned short NETWORK_ERR = 19;
97  const unsigned short ABORT_ERR = 20;
98  const unsigned short URL_MISMATCH_ERR = 21;
99  const unsigned short QUOTA_EXCEEDED_ERR = 22;
100  const unsigned short TIMEOUT_ERR = 23;
101  const unsigned short INVALID_NODE_TYPE_ERR = 24;
102  const unsigned short DATA_CLONE_ERR = 25;
103};
104
105// XXXkhuey copy all of Gecko's non-standard stuff onto DOMException, but leave
106// the prototype chain sane.
107DOMException includes ExceptionMembers;
108