What is a recommended way to handle exception/errors in larger projects?
Is there similar mechanism as RAII in C++ (can I be sure that a resource is cleaned if an exception is thrown; or have I always use finally
and handle resource)?
Assume an exception with some additional info, see C++ example below, what is a best way in Julia…
class MyException : public std::exception
{
public:
explicit MyException(const char* msg) :MyException(0, msg) {}
explicit MyException(int code, const char* msg) : _code{ code }, std::exception{ msg } {}
int code() { return _code; }
protected:
int _code;
};