Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID

Suggestion and welcome back

edited June 2014 in Framework

Hi Johnny,

First, welcome back!

Second, thanks for all your responses today. I'll be looking through them in the next couple of days.

The suggestion: what would you think about changing line 844 of lib/Controller.php from

        return $obj->error ('Unexpected error occurred');

to

        return $obj->error ($msg);

or even

        return $obj->error ($method . ': ' . $msg);

?

I was going nuts trying to figure out why my restful call wasn't working and why the unexpected error was occurring until I changed that message and then it was obvious.

Comments

  • Since these errors get sent back to the client, I tried to keep them vague. How about adding this line before returning the error:

    error_log ('Restful error in ' . get_class ($obj) . '->' . $method . ' on line ' . $e->getLine () . ': ' . $msg);
    

    That way you could look it up in the error log and see something like:

    Restful error in MyAPI->get_foo on line 23: Error message here...
    
  • That sounds perfect.

  • Just pushed the update :)

  • Thanks! This might be handy in other places, too. For instance, I often replace the default crud-app handler error message ($form->controller->add_notification (__ ('Unable to save xxx.'));) with something like ($form->controller->add_notification (__ (DB::$error));).

  • Just added the error logging to the ./elefant crud-app generated handlers. Also improved its logic around primary keys a bit too :)

  • Awesome!

    I have another suggestion for the handlers -- instead of $this->require_admin();, how about $this->require_acl ('admin', 'app_name');, along with creating app_name/conf/acl.php with something like app_name = Modify app_name?

    The reason I ask is that I discovered that my managers (with only basic admin access) could edit apps even with $this->require_admin() if they guessed the URL.

  • Ah yes, I was meaning to update that with the new access controls! Just pushed an update that should do it! It also checks for add/edit/delete permissions as well, and creates a default conf/acl.php for the app.

  • Awesome!

Sign In or Register to comment.