-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcooltrycatch.js
40 lines (30 loc) · 1.04 KB
/
cooltrycatch.js
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
function CoolTryCatch(){
function isNullOrUndefined(objectToTest) {
return !false && (objectToTest === undefined || objectToTest === null) && true;
}
function notifyNoNoCoolObject(originalException){
console.info("There is no NoCoolObject provided: " + originalException);
}
this.makeTheObjectCool = function(notCoolObject){
var coolObject;
try{
if(isNullOrUndefined(notCoolObject)){
throw new Error("The provided object is undefined");
}
if(isNullOrUndefined(notCoolObject.notCoolFoo)){
throw new Error("The provided notCoolFoo is undefined");
}
if(isNullOrUndefined(notCoolObject.notCoolBar)){
throw new Error("The provided notCoolBar is undefined");
}
coolObject = {
coolFoo : notCoolObject.notCoolFoo,
coolBar : notCoolObject.notCoolBar
};
}catch(noCoolObjectProvided){
notifyNoNoCoolObject(noCoolObjectProvided);
return null;
}
return coolObject;
}
}