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

  • SEARCH
  • Home
  • 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 8131123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:59:08+00:00 2026-06-06T08:59:08+00:00

I am attempting to provide user friendly error messages via my web application for

  • 0

I am attempting to provide user friendly error messages via my web application for certain errors. I want to be able to pass the throw exception call and extra paramter, such like “USER” so the error controller gives this paramter to the view and displays a different style page with maybe a more friendly color and a meaningful message, but I can’t figure out how to pass extra arguments. Here is the current setup:

Some check in one of the controllers:

throw new Zend_Controller_Exception("User not found",403);

Error controller (ErrorController.php):

class ErrorController
    extends Zend_Controller_Action
    {
        public function errorAction()
        {
        $errors = $this->_getParam('error_handler');
        switch ($errors->type) {

etc.

So I want to be able to do like:

$this->view->type = $this->_getParam('type');

in the controller, so I can do this in the view:

if($this->type == "USER") {
    some css stuff
    echo $this->exception;
  • 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-06-06T08:59:11+00:00Added an answer on June 6, 2026 at 8:59 am

    Sounds like you could:

    1. Create a custom exception class (My_Exception_UserFriendly or the like) that accepts your other parameters

    2. In a controller (or elsewhere) throw this exception with your custom params, and

    3. Use an instanceof check in your ErrorController to populate your view variables.

    And, as you already note, make sure your view checks for the presence of that user-friendly data before attempting to render it.

    Update

    Actually, reading more closely, it doesn’t look like you need the exception to carry any additional information. Simple creating a custom class should be sufficient for your detection/rendering purposes.

    You can create an empty (!) exception class in library/My/Exception/UserFiendly.php:

    class My_Exception_UserFriendly extends Exception
    {
    }
    

    Then when you encounter an error that you would like to show to the user in a friendly way, just throw an exception of this type:

    if ($rainyDay){
        throw new My_Exception_UserFriendly('Seeing some inclement weather, I\'m afraid');
    }
    

    Then in your ErrorController::errorAction():

    $exception = $this->_getParam('error_handler')->exception;
    if ($exception instanceof My_Exception_UserFriendly){
        $this->view->friendlyErrorMessage = $exception->getMessage();
    }
    

    Finally, down in your view-script error/error.phtml:

    <?php if ($this->friendlyErrorMessage): ?>
    <h2>With Humble Apologies, Valued User</h2>
    <p><?= $this->escape($this->friendlyErrorMessage) ?></p>
    <?php endif; ?>
    

    In fact, some would argue that the specific message we render is purely a view consideration. In that case, you could create a custom exception – perhaps extending this generic UserFriendly exception – for each friendly message you wish to support. Then in your ErrorController, detect the specific sub-type and set a key in the view identifying that subtype. Then, in the view, render the specific friendly message corresponding to the given key. Might be overkill just for the sake of purity, but throwing it out there for those who value those considerations.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to provide a confirmation link in my user welcome email and I'm
I am attempting to provide a web-based solution for users to select a file
I am attempting to authenticate via X.509 smart card to my application. For the
I am attempting to simply acquire the user's GPS location, but my application crashes
i'm attempting to provide a facility on my site that allows a user to
Attempting to get Spring internationalization working. I have used classpath:messages basename, created .properties files
I want to try something different, and am attempting to display an overlay on
I'm attempting to use Flask and the Flask-Login extension to implement user authentication in
I am attempting to allow a user to type in their search query in
I am attempting to add BASIC authentication to my RESTful web-service. Currently I have

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.