Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87699 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 86342 invoked from network); 10 Aug 2015 14:41:30 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Aug 2015 14:41:30 -0000 Authentication-Results: pb1.pair.com header.from=scott@paragonie.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=scott@paragonie.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain paragonie.com from 209.85.192.41 cause and error) X-PHP-List-Original-Sender: scott@paragonie.com X-Host-Fingerprint: 209.85.192.41 mail-qg0-f41.google.com Received: from [209.85.192.41] ([209.85.192.41:34968] helo=mail-qg0-f41.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FD/50-18279-918B8C55 for ; Mon, 10 Aug 2015 10:41:29 -0400 Received: by qgj62 with SMTP id 62so93422298qgj.2 for ; Mon, 10 Aug 2015 07:41:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type:content-transfer-encoding; bh=rt+T338IM2KGKPjYQOL0A+9XGaIS9SvPWsqIpXb6100=; b=eCpLJt8Gw06dS2hLVOxL+SrJvYhsKcfIfFSDCAvPTbKR50wlps75wiWQIj/GoeaASX 6/KDetfaV9/aWHFyaPSupCvmx4V8kfnw40Pagot7Rv1KSRcoUKAato+Kp/GSZs9YSrto L2qo9bpw3KQDa8wAzkVOyg24hMYdX0bLaYWiQVqNwYA9yAofKRnfBhtW+aB93nEkXdq0 y8AS+IZckZNiIomrcDn76mLNYeL+7JVNV3auYJVh9n8OoPrBDrOjQT6mD0jmyorurXFt Ftkcr1CIq+XeTLOlPMtUkMnIS8QEK8EhV1rVBGcIyjw3mzCJ2xLBc7L70bpKmPruNG2f lX1w== X-Gm-Message-State: ALoCoQn72KhyNgHDrn5gWxpeg2If/mJO4ihzmCj9diN3BTmEVzp4uSh4wQ9PL+gtiQsUZ5pUCaUf MIME-Version: 1.0 X-Received: by 10.140.196.8 with SMTP id r8mr41027742qha.25.1439217687102; Mon, 10 Aug 2015 07:41:27 -0700 (PDT) Received: by 10.96.83.102 with HTTP; Mon, 10 Aug 2015 07:41:27 -0700 (PDT) In-Reply-To: References: <99CE9AAF-E6E9-4D37-B462-E4A63139EAFB@icicle.io> Date: Mon, 10 Aug 2015 10:41:27 -0400 Message-ID: To: PHP Internals Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Recap - Core functions throwing exceptions in PHP7 From: scott@paragonie.com (Scott Arciszewski) On Thu, Aug 6, 2015 at 4:52 AM, Niklas Keller wrote: > Scott, could you setup a RFC with a vote, so we can decide? > > Nikita proposed those two options: > >> 1) Error is to be used in cases where an error is attributable to >> programmer mistake. >> >> >> >> 2) Error signifies a failure condition that the programmer is discourage= d >> (and unlikely to want) to handle. It should only be dealt with at the to= p >> level. > > > I'm in favor of 2), I would phrase it like: Error should be used if a > repetitive call with the same input parameters would _permanently_ result= in > a failure, otherwise Exception. > > Regards, Niklas ------------ On Fri, Aug 7, 2015 at 1:38 AM, Aaron Piotrowski wrote: > >> On Aug 6, 2015, at 3:52 AM, Niklas Keller wrote: >> >> Scott, could you setup a RFC with a vote, so we can decide? >> >> Nikita proposed those two options: >> >>> 1) Error is to be used in cases where an error is attributable to >>> programmer mistake. >>> >> >> >>> 2) Error signifies a failure condition that the programmer is discourag= ed >>> (and unlikely to want) to handle. It should only be dealt with at the t= op >>> level. >> >> >> I'm in favor of 2), I would phrase it like: Error should be used if a >> repetitive call with the same input parameters would _permanently_ resul= t >> in a failure, otherwise Exception. >> >> Regards, Niklas > > I=E2=80=99m in favor of 1), as this was my original intention of the Erro= r branch of > exceptions. Errors should be attributable to a programming mistake that s= hould > be corrected. Exception should be thrown for unexpected conditions that a= re not > due to programmer error, but instead things like IO or permission errors.= I think > this is how exceptions thrown from core functions (and all functions or m= ethods in > extensions) should be organized. > > Based on this interpretation, random_int() should throw an Error if $min = > $max > and random_bytes() should throw an Error if $length <=3D 0. random_bytes(= ) and > random_int() should throw an Exception if random data cannot be generated= . > > Another quote from Nikita=E2=80=99s message to the prior thread: > >> Another interesting aspect are the zpp calls. Currently these will throw= a >> warning and return NULL in weak mode and throw a TypeError in strict mod= e. >> I wonder whether we should be using zpp_throw for new functions, so a >> TypeError is also thrown in weak mode. Continuing to use the old >> warning+NULL behavior was a BC concern, which we don't have for new >> functions. The reason why I think this is worth considering, is that if = all >> other error conditions of a function already throw, then ordinary zpp wi= ll >> still add one case where a different type is returned on error. This mak= es >> random_int from a function returning int, to a function returning int|nu= ll. > > I would also be in favor of throwing TypeError from zpp calls in new func= tions > (and quite frankly, from zpp calls in all functions, including old functi= ons). > > Regards, > Aaron Piotrowski > Okay, great, we have people on both sides on this discussion. I hope nobody minds if I sit this part out. What specifics need to be discussed? Should somebody set up a poll? (I don't know how to do that.) Scott Arciszewski Chief Development Officer Paragon Initiative Enterprises