Skip to content
This repository has been archived by the owner on Jul 5, 2022. It is now read-only.

Fix fatal error with exception factory #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

seyfer
Copy link

@seyfer seyfer commented Jan 28, 2015

No description provided.

@alonpeer
Copy link

Hi,

Thanks for your input.

Can you please explain which fatal error you're trying to resolve? Is the translation function __ causing issues? How can I reproduce the fatal error?

Also, I'd like to be compliant with Kohana standards, so please use tab characters instead of spaces. It'll also help me see exactly which changes you've made in the file.

@seyfer
Copy link
Author

seyfer commented Jan 29, 2015

throw HTTP_Exception::factory(400, array(
                'error' => __('Missing name'),
                'field' => 'name',
            ));

Try it with php5.5 and kohana 3.3.2.
I have fatal error with message, that we can't use array as exception message, only string.
In my pull I fix arrays to strings and now it's works.

@seyfer
Copy link
Author

seyfer commented Jan 29, 2015

About Kohana standard - it's anachronism. There is only one standard now - PSR-2.
See this discussion.
kohana/core#597

@alonpeer
Copy link

Re PSR-2: I haven't worked with PHP in general, and Kohana in particular, for almost a year now. So cool, PSR-2 isn't great, but I'd prefer to make this change in the entire module (and parent module) code base in a separate pull request which refactors ALL files for PSR-2 standard.

Re bug: I've actually extended Kohana_HTTP_Exception in my module, so that the constructor gets an array with 2 values. See: https://github.com/SupersonicAds/kohana-restful-api/blob/master/classes/HTTP/Exception.php
Please make sure you clear your cache, maybe that's the reason for the fatal error.
Also, notice that they changed the class path folder from lower case http to upper case HTTP between Kohana 3.2 and 3.3 (https://github.com/kohana/core/blob/3.2/master/classes/http/exception.php vs. https://github.com/kohana/core/blob/v3.3.2/classes/HTTP/Exception.php), so this might also be a reason why my class override didn't load for you.

@seyfer
Copy link
Author

seyfer commented Jan 29, 2015

I'm using 3.3, why you talking about 3.2 ?

And I have own override for HTTP_Exception in my application for custom error handler, maybe this is the reason.

@alonpeer
Copy link

Yes, that's the reason.
I guess I need to find another way of overloading Kohana_HTTP_Exception, while keeping the functionality I implemented. I'll probably do it with normal inheritance instead of Kohana overloading mechanism.
Thanks for catching this.

@seyfer
Copy link
Author

seyfer commented Jan 29, 2015

Yes, you can just inherit your own rest_exception and problem will gone.

Thank you for answer.

@seyfer
Copy link
Author

seyfer commented May 15, 2015

What the status of problem solving? :)

@RamonSmit
Copy link

Guess there is no fix for this?

@alonpeer
Copy link

alonpeer commented Mar 4, 2016

@unbalanced ?

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

Successfully merging this pull request may close these issues.

3 participants