Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 1 of 1
  1. #1
    CPD
    CPD is offline
    Member
    Join Date
    May 2012
    Location
    South London, England
    Posts
    36
    Member #
    31775
    Liked
    5 times
    Just had a thought this morning about throwing exceptions and returning.

    If you throw an exception am I correct in thinking you shouldn't then return false or null as the exception being thrown ultimately flags a problem therefore no return value is required?

    PHP Code:
    function foo(x){
        if(
    x==1){
            throw new 
    Exception;
        }
        return 
    true;
    }

    // As opposed to

    function bar(y){
        if(
    y==1){
            throw new 
    Exception;
            return 
    false;
        }
        return 
    true;


  2.  


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 05:06 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com