try catch exception and log ex and stacktrace