Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I have two instances of Laravel: Rest Server API and Rest Client. Let's say I want to display list of positions on the front page. I'm making request to my Server API from my client controller:

public function add_employee() {
    $data['employee_positions'] = Client_API::generic_request('/employees/position_list');
    $this->layout->content = View::make('employees.add_employee')->with($data);

If my API request returns 400-500 errors, I want my application be redirected to login page. Where should I validate my API responses?

I can't do redirects in my Client's Client_API wrapper class. So far, the only way I can accomplish it is by validating responses before returning them inside Client_API class and in case of 400-500 error - I'm throwing Exception, and then handling my business logic (redirects) inside catching exceptions function. I've been told that Exceptions shouldn't be used as a part of business processes inside my application.

share|improve this question

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.