Re: Standardized way of interpolating variables into PEAR_Exceptionmessages?

From: Date: Sun, 24 Sep 2006 02:52:05 +0000
Subject: Re: Standardized way of interpolating variables into PEAR_Exceptionmessages?
References: 1 2  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-44022@lists.php.net to get a copy of this message
Alexey Borzov wrote: >> The problem with this approach is that it becomes very difficult to >> internationalize the message strings -- which is why, in my definition >> for File_MARC_Exception near the bottom of >> http://marc.coffeecode.net/highlight_MARC.php, I've >> defined the error >> codes as class constants and a static array of messages with the error >> codes as the keys to the array. > > > What's wrong with more-or-less standard > throw new Foo_Exception(sprintf(_('The value of VAR cannot be '%s'), > $var)); > why reimplement it? > And why it is reimplemented in ErrorStack in the first place? Alexey, ErrorStack allows passing in arrays (auto-joining to comma-separated lists) and objects as well as strings. sprintf() doesn't do that. Greg

« previous php.pear.dev (#44022) next »