Skip to content

Commit 6bc5ad5

Browse files
authored
Merge pull request mouredev#4231 from raulG91/raulG91
#10 - Javascript
2 parents 7cfa97a + 7448b57 commit 6bc5ad5

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
try{
3+
myFunctionUndefined()
4+
}catch(error){
5+
console.log("There is an error")
6+
console.log(error.name)
7+
}
8+
9+
class CustomError extends Error{
10+
11+
constructor(){
12+
13+
super("Custom message");
14+
15+
}
16+
}
17+
18+
19+
function myFunction(param1,param2){
20+
if(param1 <= 3){
21+
throw new CustomError();
22+
}
23+
else if (typeof(param2)!= "number"){
24+
throw TypeError("Int was expected");
25+
}
26+
else if(param2>= 6){
27+
throw Error("Value bigger than 6");
28+
}
29+
}
30+
31+
try{
32+
//myFunction(1,4);
33+
//myFunction(8,"ed");
34+
myFunction(8,16);
35+
36+
}catch(err){
37+
38+
console.log("Exception name ", err.name);
39+
console.log("Exception message ", err.message);
40+
}
41+
42+
console.log("Execution finished ")

0 commit comments

Comments
 (0)