Giter Site home page Giter Site logo

Comments (12)

stickgrinder avatar stickgrinder commented on April 27, 2024

I think this should throw an exception instead than just return false. In fact it is not that provided data doesn't match validation, but it's the software that's broken since a component is missing.
I could bear with this since I'm working on form components.

from codeigniter.

stickgrinder avatar stickgrinder commented on April 27, 2024

I took a look into Form_validation library and current behavior is to log a debug message for non existent function without breaking execution.
It is not that desirable, actually, since this weaken validation, that should be strengthen instead. Someone from Reactor team on this?

from codeigniter.

kenjis avatar kenjis commented on April 27, 2024

I agree to throwing an exception. This current spec is too dangerous.

from codeigniter.

freewil avatar freewil commented on April 27, 2024

+1, throw exception.

from codeigniter.

kenjis avatar kenjis commented on April 27, 2024

@freewll, your hack does not throw an exception.

When this error happens, it is a bug. So I think error message for users is not required, only throwing an exception is enough. If you does not catch the exception, PHP fatal error occurs.

from codeigniter.

freewil avatar freewil commented on April 27, 2024

I don't think an exception is appropriate considering the current framework. I'm not aware of anywhere else in CI where an exception is thrown.

from codeigniter.

stickgrinder avatar stickgrinder commented on April 27, 2024

Actually I checked the core and exceptions are not the framework preferred instrument to raise errors. Still if I understand correctly, your fix simply logs an error message and nothing more.

It would be better to use show_error() helper, that mimic exceptions handling while remaining compatible with better error reporting tools such as Uh-Oh. As Kenjis pointed out, trying to call a non existent function should result in execution stop, both in framework and in language philosophy! :)

HTH.

from codeigniter.

stickgrinder avatar stickgrinder commented on April 27, 2024

FYI, here is a brief post that explains advantages of using CI's core error handling: http://www.derekallard.com/blog/post/error-handling-in-codeigniter

My bad, I thought to an Exception, but you're right: CI doesn't advocate exceptions. show_error() should be the right way to go. :)

from codeigniter.

kenjis avatar kenjis commented on April 27, 2024

You guys are right. But the article was written in 2007!
CI had supported PHP4 until before CI2.0, so there was no Exception, try/catch/throw.

If we throw Exception, we need to hear the policy about Exception from Reactor team and/or EllisLab.

from codeigniter.

stickgrinder avatar stickgrinder commented on April 27, 2024

Well, actually this is an issue with a lot of topics. Since last steering from Reactor team (all the github migration, Core and Reactor merging and various stuff) it seems a lot could change. But as far as I know there is no intention to drastically change the way CI behaves (that's one of the reasons that led to Fuel creation: they didn't feel changing the mindset of CI was right), so as far as I can tell, if coding guidelines are unavailable, the only thing to do is clone the repo and grep for "throw", "try" and "except" in system directory.

If nothing can be found, well, my bet is nothing is changed since 2007 on that side! ;)

from codeigniter.

freewil avatar freewil commented on April 27, 2024

I closed my pull request and agree with @stickgrinder that show_error() should be used instead.

from codeigniter.

stickgrinder avatar stickgrinder commented on April 27, 2024

I'll try to send a pull-req ASAP with a show_error() integration.

from codeigniter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.