I\'ve been doing a lot of research about handling errors with Qt/C++ and I\'m still as lost as when I started. Maybe I\'m looking for an easy way out (like other languages p
I prefer error handling using exceptions. Please find the below sample code:
ErrorStatus ExplodeToLine()
{
var errorStatus = new ErrorStatus();
try
{
errorStatus = fun();
if (!errorStatus.ok())
{
throw new VicException(L"fun failed");
}
errorStatus = fun1();
if (!errorStatus.ok())
{
throw new VicException(L"fun1 failed");
}
errorStatus = fun2();
if (!errorStatus.ok())
{
throw new VicException(L"fun2 failed");
}
errorStatus.setError(ErrorType.OK);
}
catch (VicException vicExp)
{
Log(vicExp.errorMsg());
}
catch (Exception exp)
{
Log(exp.errorMsg());
}
return error_status;
}