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

3.0 Custom exception handling method name #5770

Closed
glafarge opened this issue Jan 28, 2015 · 1 comment
Closed

3.0 Custom exception handling method name #5770

glafarge opened this issue Jan 28, 2015 · 1 comment
Milestone

Comments

@glafarge
Copy link
Contributor

I used a vendor API (=Mailchimp) which had it's own Exception naming conventions.

I want to change how Mailchimp_List_AlreadySubscribed (exception) is rendered and I used a custom exception handler.

namespace App\Error;

use Cake\Error\ExceptionRenderer;

class AppExceptionRenderer extends ExceptionRenderer
{
    public function mailchimpListAlreadySubscribed($error)
    {
        return 'Oops the user is already subscribed to the list !';
    }
}

Never called.

When I saw how CakePHP gets the method name, I understand why it doesn't works...

$baseClass = substr($baseClass, 0, -9);

    protected function _method(\Exception $exception) {
        list(, $baseClass) = namespaceSplit(get_class($exception));
        $baseClass = substr($baseClass, 0, -9);
        $method = Inflector::variable($baseClass) ?: 'error500';
        return $this->method = $method;
    }

It searches for mailchimpListAlreadyS() method instead of the complete name because of substr().

What do you think about this ?
I have already made a change to it but I don't know if it's a good approach.

@jadb
Copy link
Contributor

jadb commented Jan 28, 2015

Closing as #5771 is now open.

@jadb jadb closed this as completed Jan 28, 2015
@jadb jadb added this to the 3.0.0 milestone Jan 28, 2015
markstory added a commit that referenced this issue Jan 30, 2015
When rendering custom exceptions the exception renderer should not
mangle names that do not end in 'Exception'.

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

No branches or pull requests

2 participants