Re: [Tiki-devel] Is this why Exceptions are mostly dead in tiki? And they must be changed with Trowable?
Jonny Bradley via TikiWiki-devel <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.devel |
|---|---|
| Message-ID | <[email protected]> |
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 >