Re: [Tiki-devel] Is this why Exceptions are mostly dead in tiki? And they must be changed with Trowable?
aris002 via TikiWiki-devel <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi all and @Jonny, I used Throwable instead Exception because I was getting empty messages when I started implementing Hybridauth with Tiki. Then when I faced my last problem with installation I noticed again that some exceptions didn't work again or didn't give any indication of an error and only when I changed to Throwable i was able to get some relevant info.(From mysql, btw)and then I found that clearly unfinished and empty Exception block I mentioned earlier when I grew even more suspicious about the quality of exception handling in tiki.That's why and how I started searching for more info about Exception handling and found that info on PHP.NET So, I thought, exception handling with the Exception doesn't work at all. I am still quite new to php and I am not that deep into it and haven't studied their compiler source nor haven't tested a lot of other cases.As I understand now, Throwable just gives more detailed information and then there is no need to implement separate interfaces with Exception... But if those interfaces fully cover the errors then is OK, as it is with the Exception. I am just still worried in how many cases Tiki misses to throw those Exceptions and to show relevant info?Sorry, if that is not the case. I just felt obliged to ask and wanted to know the reason why Tiki not switched to using Thowable.And encourage other tiki developers to show as much as possible diagnostic info. And not to leave empty exception blocks. Best regards,Aris On Tuesday, 20 July 2021, 11:52:45 EEST, Jonny Bradley via TikiWiki-devel <[email protected]> wrote: Hi Aris We only have 10 uses of Throwable in Tiki afaics (3 of them, by you ;) - i have to admit i haven't got into the habit of using yet them i'm afraid. Exception catching still works the same in php7, from what i can see Throwable can mean an Error or an Exception https://stackoverflow.com/a/35266215/2459703 So i think the Exception catch is only redundant if there is a Throwable catch too... I'm not sure what you mean by "Exceptions are mostly dead in tiki", sorry? jonny > On 20 Jul 2021, at 00:10, aris002 via TikiWiki-devel <[email protected]> wrote: > > Re: > PHP5 is no longer needed, but it would be nice to have a nice error > message if someone tries. > > then maybe we still need my original idea from the first post: > > To catch both exceptions and errors in PHP 5.x and 7, add a catch block for Exception AFTER catching Throwable first. > Once PHP 5.x support is no longer needed, the block catching Exception can be removed. > > try > { > // Code that may throw an Exception or Error. > } > catch (Throwable $t) > { > // Executed only in PHP 7, will not match in PHP 5 > } > catch (Exception $e) > { > // Executed only in PHP 5, will not be reached in PHP 7 > } > > >> On Tuesday, 20 July 2021, 00:54:32 EEST, <[email protected]> wrote: >> >> >> Please see below >> >> >> On 2021-07-20 00:13, aris002 via TikiWiki-devel wrote: >>> > Thanks Marc, >>> > >>> > 1. Glitch is a very good thing but I guess will it work during tiki >>> > installation proccess? About which I am worried mostly at the moment. >> >> >> Ah, good point. >> >> As of now, GlitchTip is just post-install. >> >> >> >>> > 2. And to send login data to somewhere maybe is not the best idea? >> >> Indeed. GlitchTip is Open Source, so devs can self-host: >> https://glitchtip.com/documentation/install >> >> >>> > 3. And will it work as it is with the Exception keyword at all because >>> > documentiontion says: >>> > >>> >> >> I don't know. >> >> PHP5 is no longer needed, but it would be nice to have a nice error >> message if someone tries. >> >> Best regards, >> >> Marc >> >>> > catch (Exception $e) >>> > >>> > { >>> > // Executed only in PHP 5, will not be reached in PHP 7 >>> > } >>> > >>> > PHP: Errors in PHP 7 - Manual [1] >>> > >>> > PHP: ERRORS IN PHP 7 - MANUAL >>> > >>> > Regards, >>> > Aris >>> > >>> > On Monday, 19 July 2021, 23:59:37 EEST, Marc Laporte >>> > <[email protected]> wrote: >>> > >>> > Hello Aris, >>> > >>> > Not an answer to your question, but here is some information related >>> > to error tracking. >>> > >>> > Here is a new feature in Tiki23: >>> > * https://dev.tiki.org/GlitchTip >>> > * https://doc.tiki.org/GlitchTip >>> > >>> > We'll centralize error messages from various community sites, and this >>> > will make it easier to resolve. >>> > >>> > We can imagine in the future that each error message shown to end >>> > users would have a unique ID, and this will help provide actionable >>> > information to developers to solve the problems at the source. >>> > >>> > Best regards, >>> > >>> > Marc >>> > >>> > On Mon, 19 Jul 2021 20:42:20 +0000 (UTC) Tiki developers >>> > [email protected] said >>> > >>> >> Hi again, >>> >> >>> >> Is this why Exceptions are mostly dead in tiki? And they must be >>> > changed with >>> >> Trowable? >>> >> >>> >> Writing Code to Support PHP 5.x and 7 Exceptions >>> >> To catch any exception in PHP 5.x and 7 with the same code, multiple >>> > catch >>> >> blocks can be used, catching Throwable first, then Exception . >>> > Once PHP >>> >> 5.x support is no longer needed, the block catching Exception can >>> > be >>> >> removed. >>> >> try { // Code that may throw an Exception or Error. } catch ( >>> > Throwable $t ) >>> >> { // Executed only in PHP 7, will not match in PHP 5.x } catch ( >>> > Exception $e >>> >> ) { // Executed only in PHP 5.x, will not be reached in PHP 7 } >>> >> Writing catch-all block compatible with both PHP 5.x and 7 >>> >> Unfortunately, type declarations on functions that handle exceptions >>> > are not >>> >> as easy to fix. If Exception is used as a type declaration on a >>> > function >>> >> parameter, the type declaration will need to be removed if the >>> > function could >>> >> be called with an instance of Error . When PHP 5.x support is not >>> > required, >>> >> the type declaration can be restored as Throwable . >>> >> >>> >> Thanks, >>> >> Aris >>> > >>> > _______________________________________________ >>> > TikiWiki-devel mailing list >>> > [email protected] >>> > https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel >>> > >>> > >>> > Links: >>> > ------ >>> > [1] https://www.php.net/manual/en/language.errors.php7.php >>> >>> > _______________________________________________ >>> > TikiWiki-devel mailing list >>> > [email protected] >>> > https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel >> >> >> _______________________________________________ >> TikiWiki-devel mailing list >> [email protected] >> https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel >> _______________________________________________ >> TikiWiki-devel mailing list >> [email protected] >> https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel > _______________________________________________ TikiWiki-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel _______________________________________________ TikiWiki-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel