-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrollbar_error.js
More file actions
58 lines (45 loc) · 1.1 KB
/
rollbar_error.js
File metadata and controls
58 lines (45 loc) · 1.1 KB
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
56
var button = document.createElement("button");
button.innerHTML = "Create an error";
var body = document.getElementsByTagName("body")[0];
body.appendChild(button);
function multiplication(n1, n2) {
try {
throw "blah";
} catch(err) {
alert("I am an error message")
}
return n1 * n2;
}
function numero(num) {
try {
throw new Error("Something went wrong inside numero");
} catch (e) {
Rollbar.error(e);
}
return num;
}
button.addEventListener ("click", function() {
console.log(multiplication(numero(2), 4));
});
function myFunction() {
var message, x;
message = document.getElementById("p01");
message.innerHTML = "";
x = document.getElementById("demo").value;
try {
if(x == "") throw "empty";
if(isNaN(x)) throw "not a number";
x = Number(x);
if(x < 5) throw "too low";
if(x > 10) throw "too high";
}
catch(err) {
message.innerHTML = "Input is " + err;
}
}
try {
throw new Error("Something went wrong");
} catch (e) {
console.log('This is challenging but I like challenges')
Rollbar.error(e);
}