-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-errors.html
55 lines (46 loc) · 1.48 KB
/
test-errors.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<body style="background-color: #E2E2FF;">
<button onclick="myFunction()">ReferenceError</button>
<button onclick="myFunction2()">TypeError</button>
<button onclick="myFunction3()">RangeError</button>
<button onclick="myFunction4()">RangeError 2</button>
<button onclick="myFunction5()">URIeError</button>
<button onclick="throwSomething()">Throw Custom Error</button>
</body>
<script src="test-errors.js"></script>
<script>
function myFunction2(){
myArray = [];
myString = myArray[0]
myString.substring(0,5);
}
function myFunction3(){
myFunction3();
}
function myFunction4(){
var x = new Array(0.5);
}
function myFunction5(){
x = encodeURI('\uD800')
}
/*function myFunction6(){
this = 2;
}*/
// Create an object type UserException
function UserException(message) {
this.message = message;
this.name = "UserException";
}
// Make the exception convert to a pretty string when used as a string
// (e.g. by the error console)
UserException.prototype.toString = function() {
return this.name + ': "' + this.message + '"';
}
function throwSomething(){
// Create an instance of the object type and throw it
throw new UserException("Value too high");
}
//HELPFUL
//https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error
//https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Control_flow_and_error_handling#Exception_Handling_Statements
//http://www.webreference.com/programming/javascript/rg31/index.html
</script>