Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4020860
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:16:50+00:00 2026-05-20T10:16:50+00:00

Any tips on how to handle business logic errors? I do not mean Exceptions.

  • 0

Any tips on how to handle business logic errors? I do not mean Exceptions.
For example, lest assume that i have a class:

<?php
class Reactor () {  // business class 
    public function shutdown() {  
    if($date > '2 pm') {  
        // show error message to user  
        echo 'you can't shutdown before 2 pm.';  
       } else {  
        // error while trying to shutdown  
           throw new Exception('Oh my God, it is gonna blow!!');  
        }
    }
}
?>

The real question is how to pass the error message to my views?
Exceptions are good for exceptional cases. I’m very close to add ErroMessage and ErrorCode attributes to the base business class and check it every time i call a business class method.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T10:16:51+00:00Added an answer on May 20, 2026 at 10:16 am

    You’re actually on the right track here. You can handle the exceptions in your ErrorController – a convention modeled in Zend, but in many other frameworks too. You can create your own if you’re rolling it DIY.

    This thread has a more Zend-centric method of handling, but you can use the ErrorController to actually render your view. Handle the input of the $e exception class and get the message from that.

    Throwing exceptions from model/view/controller in a Zend Framework application

    If you’re deep in the DIY route, you can display it gracefully if you wrap your larger blocks in try/catch and test all instances of the exception class. For instance:

    class Reactor () {  // business class 
        public function shutdown() {  
        if($date > '2 pm') {  
            // show error message to user  
            echo "you can't shutdown before 2 pm.";  
           } else {  
            // error while trying to shutdown  
               throw new Exception('Oh my God, it is gonna blow!!');  
            }
        }
    }
    
    //later, in the controller
    
    $reactor = new Reactor();
    try{
      $reactor->shutdown('1pm');
    } catch(Your_Custom_Exception $e){
      //pass to view
      $this->view($e->getMessage());
    } catch(Exception $e){
      // woops, serious error. do something useful
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone have any tips for dealing with ConstraintExceptions thrown by XSD datasets? This
Do you have any tips for effective profiling using Netbeans? The profiler is quite
Does anyone have any tips or gotcha moments to look out for when trying
Does someone have any tips/advice on database design for a web application? The kind
Have you guys and gals got any tips or hacks for making the most
What modes are the best? And any tips or tricks that make developing java
Does anyone have any strategies/tips/traps for moving to Team System? Should it be done
I have a UITableView that loads remote data from the network. I have logic
I have a class that handles all the interaction in my application with my
I'm trying to parse an INI file using C++. Any tips on what is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.