When is a function try block useful?

You use it in constructors to catch errors from initializers. Usually, you don’t catch those errors, so this is a quite exceptional use.

Otherwise, it is useless: unless I’m proven wrong,

void f() try { ... } catch (...) { ... }

is strictly equivalent to

void f() { try { ... } catch (...) { ... } }

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)