Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67004 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 18117 invoked from network); 8 Apr 2013 21:51:42 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Apr 2013 21:51:42 -0000 Authentication-Results: pb1.pair.com smtp.mail=dor.tchizik@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=dor.tchizik@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.178 as permitted sender) X-PHP-List-Original-Sender: dor.tchizik@gmail.com X-Host-Fingerprint: 209.85.214.178 mail-ob0-f178.google.com Received: from [209.85.214.178] ([209.85.214.178:52884] helo=mail-ob0-f178.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CC/D1-06325-DEB33615 for ; Mon, 08 Apr 2013 17:51:41 -0400 Received: by mail-ob0-f178.google.com with SMTP id ni5so1725409obc.37 for ; Mon, 08 Apr 2013 14:51:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=PJMFFHUyQq9/btrzsXU7KbLqmPf66AUleUpL++pWIPw=; b=NQJJFpmM0uWc+lty6iiUFD9+D8rjcf5nuu3r88IBflVL7I/UVvWvyJmNM8h5Vxmipz 5rKF7pnkkw4fmaK/o3HfdxMMz0kLDRq9Hmj1a4D3aXtnCl+Gsly6WimegAMst5FUwK7Y Cdnuevd6WVgBKeA+jV8zjxSy1pGZnug81JP+FxbHgCgSoxiP4gwAtSfdEaKIJMnGm83H lZRb7Hvzk4K7UUmgmpX7mJnUCwVEGaROtsqwYgYowTbbjf7TzRzCHYKPqHE6UDLEZpA6 eY7K1t0Y3N7mW2UBKfdOUvJkwPZGGnL6CDoJF8P5LjG+z7hr4UZUac7K7CELimHOzd+l YXlg== MIME-Version: 1.0 X-Received: by 10.60.50.102 with SMTP id b6mr16746097oeo.46.1365457898764; Mon, 08 Apr 2013 14:51:38 -0700 (PDT) Received: by 10.182.128.69 with HTTP; Mon, 8 Apr 2013 14:51:38 -0700 (PDT) In-Reply-To: References: Date: Tue, 9 Apr 2013 00:51:38 +0300 Message-ID: To: Thomas Anderson Cc: PHP Internals Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] trigger_error() enhancements From: dor.tchizik@gmail.com (Madara Uchiha) What's wrong with set_error_handler()? http://php.net/manual/en/function.set-error-handler.php (Aside for the fact that any uncaught warning would be fatal). On Mon, Apr 8, 2013 at 11:51 PM, Thomas Anderson wrote: > 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?