added try catch implementation in C