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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:23:13+00:00 2026-06-13T16:23:13+00:00

What do you think about this composition? Is it wrong? How to do it

  • 0

What do you think about this composition? Is it wrong? How to do it properly?

$graph_url = 'https://graph.facebook.com/me?access_token=' . $result['access_token'];
$fb_user = json_decode( file_get_contents( $graph_url ) );
try {
    $user = new Model_User( $fb_user->username );
    $user_meta = new Model_User_Meta ( $user->get ( 'user_id' ) );
    $user_meta->set_user_meta( '_facebook_id', $fb_user->id );
    $user_meta->set_user_meta( '_last_logged_in', 'current_timestamp' );
    $user_meta->save();
} catch ( Exception $e ) {
    if ( $e->getCode() === 0 ){
        $password = Helper_Password::generate_password();
        $hash = Helper_Password::hash_string( $password );
        try {
            $user = new Model_User();
            $user->set( 'user_name', $fb_user->username );
            $user->set( 'user_pass', $hash );
            $user->set( 'user_email', $fb_user->email );
            $user->set( 'user_status',( $fb_user->verified ? 'active' : 'inactive' ) );
            $user->set( 'display_name', $fb_user->name );
            $status = $user->save();
            $user_meta = new Model_User_Meta ( $status->user_id );
            $user_meta->set_user_meta( '_facebook_id', $fb_user->id );
            $user_meta->set_user_meta( '_last_logged_in', 'current_timestamp' );
            $user_meta->save();
        } catch ( Exception $e ) {
            throw $e;
        }
    } else {
        throw $e;
    }
}
  • 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-13T16:23:15+00:00Added an answer on June 13, 2026 at 4:23 pm

    Trying to recover during a catch, and then throwing an exception if you have to is fine.

    But you have some ambiguity in your code here. Which $e did you mean to throw? The original exception, or the new exception? If you want to throw the original exception, then you should not override $e in your second catch statement:

    } catch ( Exception $e ) {
        if ( $e->getCode() === 0 ){
            try {
                // try recovering here?
            } catch ( Exception $otherException ) {
                throw $e;  // throw the original exception instead of the new one
            }
        } else {
            throw $e;
        }
    }
    

    If you wanted to throw the new exception, you don’t need an inner catch at all…

    } catch ( Exception $e ) {
        if ( $e->getCode() === 0 ){
            // try recovering here, and let the exception fly as they will
        } else {
            throw $e;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like to know what you think about this part of our program is
I've published my website many times. But didn't think about this though until I
Think about doing this: import matplotlib.pyplot as plt plt.plot(x_A,y_A,'g--') plt.plot(x_B,y_B,'r-o') plt.show() How would you
How do you think about data access code like this: public void AddCusotmer(Cusotmer customer)
I've been thinking about this and I just can't think of a way to
I think this question is really about my understanding of Garbage collection and variable
I think this is a moderately neophyte question. I've been using NHibernate/FluentNHibernate for about
this question is about style, because i think this is a very common problem
What do you think about this Person class? Is it a bad idea or
I came to think about this question a few days ago when I desinged

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.