-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcauseInError.js
More file actions
37 lines (33 loc) · 849 Bytes
/
causeInError.js
File metadata and controls
37 lines (33 loc) · 849 Bytes
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
/*
const error = new Error(message, options);
error.message gives the message
error.cause gives options.cause
*/
const billDetails = [
{
billId: "OP908", billAmount: 58960, billDiscount: 5, date: new Date("02-02-2023"),
},
{
billId: "OP876", billAmount: 7813, billDiscount: 2.5, date: new Date("03-02-2023"),
},
{
billId: "0P908", billAmount: 0, billDiscount: 0, date: new Date("09-02-2023"),
},
];
function server(index) {
try {
billDetails[index].billDiscount;
} catch (error) {
throw new Error("Method: Server", {
cause: error
})
}
}
function getPerItemCostByCustomerId(id) {
try {
server(3);
} catch (exception) {
console.log(`${exception.message} ${exception.cause}`);
}
}
getPerItemCostByCustomerId(2);