Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

misplaced "try block" #13

Closed
Alieff opened this issue May 7, 2016 · 1 comment
Closed

misplaced "try block" #13

Alieff opened this issue May 7, 2016 · 1 comment
Assignees

Comments

@Alieff
Copy link
Owner

Alieff commented May 7, 2016

In file web/app/Http/Controllers/JsonController.php especialy from line 17 to line 34,

public function index(){
         $quotes = Quotes::all();
         $randQuote = rand(1,count($quotes));
         $quotees = $quotes[$randQuote-1];
         try{
             $statusCode = 200;
             $response = $quotees;
         }
         catch (Exception $e){
             $statusCode = 404;
             $response = "error coy";
         }finally{
             return Response::json($response, $statusCode);
             //return 'hehe';
         }
     }

I think there is misplacement in your code, it is written that the "try" block surround 2 assignment statement,

$statusCode = 200;
$response = $quotees;

as far as i know, assignment statement never throws an exception unless it include a method call, perhaps you misplace the "try" block

@haryoaw
Copy link
Collaborator

haryoaw commented May 8, 2016

Thank you @Alieff for reporting that misplaced things.

Too bad, your suggestion won't be implemented. That method is useless and won't be implemented in our website. I was going to erase that function. So just delete that method as it will not affect our website at all.

You can help us to look at the other function in this JsonController and tell us where the code goes wrong. 💃

Thanks ^_^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants