let first_function = (content: string): any => {
throw
new
Error(content);
};
let second_function = (content: string): any => {
throw
new
Error(content);
};
let third_function = (content: string): any => {
throw
new
Error(content);
};
let catchAllErrors = (callback: any, content: string): any => {
try
{
callback(content);
}
catch
(error) {
return
error;
}
};
let main_function = () => {
let error_1 = catchAllErrors(first_function,
"Error 404!!..."
);
let error_2 = catchAllErrors(second_function,
"Something went wrong!!..."
);
let error_3 = catchAllErrors(third_function,
"Please try again later!!...."
);
console.log(
"First Error: "
+ error_1);
console.log(
"Second Error: "
+ error_2);
console.log(
"Third Error: "
+ error_3);
};
main_function();