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 8795645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:26:01+00:00 2026-06-13T23:26:01+00:00

When I try to connect with the Redis server with this code I haven’t

  • 0

When I try to connect with the Redis server with this code I haven’t any problem testing if the server is UP. The problem is when the server is DOWN. In that case I solved this escenario with the classic Try/catch. My problem is that I’d like to manage this exception with “my_custom_exception” class, which has more useful functions, instead of the class Exception. Is there anyway of making this?. I know how to extend the class Exception, but in this case is a library of third parts.

function show_status_redis_server(){
    try{
        $redis = RedisDB::fetch_instance();//this ...........................
    }catch(Exception $e){
        echo "Redis server is down"; 
    }
}
  • 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-13T23:26:03+00:00Added an answer on June 13, 2026 at 11:26 pm

    As @Mike says in his comment it depends on where you want to make use of the functionality. The easiest thing is going to be to handle it in the code using the class:

    function show_status_redis_server(){
        try{
            $redis = RedisDB::fetch_instance();//this ...........................
        }catch(Exception $e){
            throw MyRedisException::createFromException($e); 
    
        }
    }
    

    or

    function show_status_redis_server(){
        try{
            $redis = RedisDB::fetch_instance();//this ...........................
        }catch(Exception $e){
            $re = MyRedisException::createFromException($e);
            // do stuff with $re here 
    
        }
    }
    

    Beynond that i can think of two ways… make a wrapper library that use the redis lib you are using but serves as an intermidary – this way you can catch the generic exceptions in your libraries classes and then throw whatever you want.

    Second way would be to just do a custom error handler that catches uncaught exceptions – inspects them for redis somehow, and then rethrows custom exceptions. However at that point you have to let the exceptions fall through until the end of execution which doesnt give you many options for handling them unless its just to format and output messages.

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

Sidebar

Related Questions

my code is this try { //Connect to the login server socket = new
I'm modifying Python code that have this form: def foo(self): try: connect socket except
I try to connect to my BD This is my code public class JavaSQLTest
When I try to connect Weblogic t3s protocol in Solaris Server, it shows this
I try to connect to a server with a self-signed certificate. I use this
First I unplug my network cable. Then I try to connect to SQL Server
Edit: Solved. Hi, I'm starting with Qt, I try to connect a slot to
try to set host in dsn of pdo like this: <?php /* Connect to
I try to connect to Facebook throught Facebook API, I follow this example: https://github.com/facebook/facebook-android-sdk/tree/master/examples/simple
When try to connect to the mysql server through my rails application, I get

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.