Error handling in controller (MVC structure) Lately, I'm using domain model pattern, and my controllers methods often looks like (yii2 example, verify user in loyalty system with Ajax response).

if (LoyaltyDomModel::loyaltyVerification($post_data)) {

    if (LoyaltyDomModel::setVerify(Yii::$app-&gt;user-&gt;identity, $post_data)) {

        return  ['body'=&gt;'successfull','status' =&gt; true];
    }
    else {
        return  ['body'=&gt;'unable update user','status' =&gt; 'error'];
    }
}
else {
    return  ['body'=&gt;'errorcardno','status' =&gt; 'error'];
}


If logic is more complex I have a lot of if statement with model methods which return bool values, for example (I'm trying to decouple models logic in atomic methods), and it looks like not healthy. Should I encapsulate logic of return errors in models? What is best practices?
I advice you forego if checks completely and go for try-catch blocks, and have your verifiers throw exceptions on error. So, you do something like this:

try {
     LoyaltyDomModel::loyaltyVerification($post_data);
     LoyaltyDomModel::setVerify(Yii::$app-&gt;user-&gt;identity, $post_data);

     return  ['body'=&gt;'successfull','status' =&gt; true];
} catch (LoyaltyVerificationException $e) {
     return ['body' =&gt; $e-&gt;getMessage(), 'status' =&gt; 'error']
} catch (UserUpdateException $e) {
     return ['body' =&gt; $e-&gt;getMessage(), 'fields' =&gt; $e-&gt;getFields(), /* you can pass custom info to exceptions, right? */, 'status' =&gt; 'error'];
}


Also, it's not a good idea to return bool in one case ('status' = true) and string in another ('status' = 'error');