1

I am running Active Collab 5.8.7 with PHP 5.6. I am using the API to create a Company and User. The API works but if there are any errors, the errors do not bubble up to the calling PHP script. I am using the approach outlined here.

try {
    $client->post('projects/65/tasks', [
      'name' => 'This is a task name',
      'assignee_id' => 48
    ]);
} catch(AppException $e) {
    print $e->getMessage() . '<br><br>';
    // var_dump($e->getServerResponse()); (need more info?)
}

The only way I can catch errors is by turning on debugging in Active Collab config.php and watching the log file. For instance, in the above example, the task_list_id is missing but it is required. I didn't figure that out until I looked in the log. I would expect that error to bubble up so I can catch it in my script.

Does anyone know how to make these errors bubble up?

Darwin von Corax
  • 5,201
  • 3
  • 17
  • 28

1 Answers1

0

Active Collab is pretty "secretive" about debugging info when running in production mode. To have the exact error logged, use debugging mode.

To turn on debug mode, open Active Collab's config/config.php and add:

const APPLICATION_MODE = 'debug';

in the block where other settings are defined. Note that you might already have APPLICATION_MODE constant defined in config/config.php in some cases, so look for it first.

Ilija
  • 4,105
  • 4
  • 32
  • 46
  • Yes when I turn on debugging, I can see the error in the log file. My question is why doesn't the API raise an exception when there is an error in the log? What is the purpose of your demos with try/catch statements if exceptions are not being raised? I tried the same thing with a duplicate company name and the API call failed silently. – Larry Morroni Jul 02 '16 at 01:54
  • When Active Collab is in debug mode, JSON 500 response should be extended with exception details. The exact error that you mention is something that we also noticed while working on this: https://github.com/activecollab/taskform (not yet done), and we found it in the response (I don't remember going through logs to find out why the request was rejected). – Ilija Jul 03 '16 at 12:44