Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67003 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 14423 invoked from network); 8 Apr 2013 20:51:28 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Apr 2013 20:51:28 -0000 Authentication-Results: pb1.pair.com smtp.mail=zelnaga@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=zelnaga@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.170 as permitted sender) X-PHP-List-Original-Sender: zelnaga@gmail.com X-Host-Fingerprint: 209.85.212.170 mail-wi0-f170.google.com Received: from [209.85.212.170] ([209.85.212.170:47709] helo=mail-wi0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B5/51-06325-FCD23615 for ; Mon, 08 Apr 2013 16:51:27 -0400 Received: by mail-wi0-f170.google.com with SMTP id hm11so4303735wib.1 for ; Mon, 08 Apr 2013 13:51:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to :content-type; bh=zO5EavgEqhVbjJcovnHHspdGbwwJo/fS4RK0JPUImtI=; b=SButwqN/9N4l2bYDKOuqW1SYK1A3FGHryd1i66sJHZ3c/LqUOTO15yeS+Ek+DBHI2R xUBMtrEQLLbjV91NNrOoOwpj6yD4CF3u5Vq1c7bGYpG7PgEZ9hWs72b8vYxgIOuidy7a M5l8mDrv1oyXG19ZbvugDUPVhol89zvtkfzo1ksB8/+JAA87NVie7Ei2TLXwJtchdwDX 1B7S6UtorJbsZr0DjlZosxOMwy/kUFIJCLR4ca6osdCeVBL2QE8hmLJKcEPEvChDqrK6 C+Om2tzZLo/zBaNPWJu8FDCiu0VPqOlnMOwmiQuJfxeRii/32DVyqOmmunKvJlzTj+Yd vNFw== MIME-Version: 1.0 X-Received: by 10.194.158.161 with SMTP id wv1mr34154025wjb.38.1365454284633; Mon, 08 Apr 2013 13:51:24 -0700 (PDT) Received: by 10.194.216.10 with HTTP; Mon, 8 Apr 2013 13:51:24 -0700 (PDT) Date: Mon, 8 Apr 2013 15:51:24 -0500 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary=089e013c6ab097bbb104d9df9959 Subject: trigger_error() enhancements From: zelnaga@gmail.com (Thomas Anderson) --089e013c6ab097bbb104d9df9959 Content-Type: text/plain; charset=ISO-8859-1 I was thinking it'd be useful if people could switch between throwing exceptions and displaying errors. If throw were a function and not a language construct one could do $function($error) where $function was a string equal to either 'trigger_error' or 'throw'. But alas that's not possible. In lieu of that it seems like it'd be useful if maybe a new error type constant could be added - E_USER_THROWABLE - that'd turn trigger_error into a throw. You wouldn't be able to use custom Exception classes in this instance but I think that'd be acceptable. ie. if you want more versatility use throw. If you just want to be able to switch between error's and thrown exceptions use trigger_error(). Also, I think it'd be useful if developers could specificy which line number and file name the error (or exception) displays For example... I was trying to implement support for stream_notification_callback in a custom stream wrapper. In my tests if you pass a non-callable string to the built-in ftp stream via, let's say, fopen(), you get an error saying "failed to call user notifier" on the fopen() line. But with custom stream wrappers the best you can do is to use trigger_error(). But that means that it's going to show not the line of the fopen() but instead the line of the trigger_error(). Which is of limited usefulness I'd say since the trigger_error() isn't where the error actually is. If a developer could control which line numbers and file names were displayed they could iterate through debug_backtrace() to get the actual line number they wanted to display. What are your thoughts? --089e013c6ab097bbb104d9df9959--