Re: [PEPr] Comment on Web Services::Service_Amazon_S3

From: Date: Mon, 25 Feb 2008 21:55:44 +0000
Subject: Re: [PEPr] Comment on Web Services::Service_Amazon_S3
References: 1 2 3  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-49196@lists.php.net to get a copy of this message
Till wrote:
WRT $doc->loadXML() I can use libxml_use_internal_errors() to prevent it from triggering errors on malformed XML.
No, see above. I wouldn't silence them.
I strongly disagree. I think silencing a notice/warning is similar to catching an exception. IMO a package shouldn't expose a lower-level error as long as it is able to handle it. In particular it shouldn't expose it, if it doesn't constitute an error in the eyes of the package. In particular, when dealing with concurrent threads, functions like unlink() or mkdir() may trigger warnings during normal operations, but as long as the code can cope with this and prevent race conditions, it isn't a problem that the user/sysadm needs to be aware of. It couldn't find a formal reference, but I think it is a widely used convention in PEAR that notices/warnings from native functions are silenced and instead reported using PEAR::raiseError or exceptions when necessary. WRT the specific use of @unlink() in my stream wrapper, this is necessary because of the STREAM_REPORT_ERRORS flag. When this is not set, the wrapper should not raise any errors.
They are probably reported for a good reason. And if people are serious about their app they will probably log everything to a logfile and will want to know about this. Personally I don't want my error log files filled with information about all kinds of runtime events but only with information about events that may indicate an error.
What do other people on the list think about this?
* Your hardcoded ".s3.amazonaws.com/", is that save to do?
[...] I was also thinking along the lines of - different datacenter, etc. pp.. I am not sure if you can abstract that through the API. For example - you can (somehow) select where your data is stored. In the U.S. or Europe (or other places as other datacenters are being build). Not sure if you need to abstract that or if the loadbalancer "behind" .s3.amazonaws.com does that for you. You can place your data in Europe using $bucket->locationConstraint = 'EU' when creating the bucket. Amazon then creates a DNS entry for yourbucketname.s3.amazonaws.com that points to the European datacenter.
During the first hours after the bucket has been created, the new DNS entry may not have been propagated so your request may still reach the US datacenter (by default, *.s3.amazonaws.com points there=. In that case you are redirected using a 307 Temporary Redirect HTTP response to a temporary hostname (something similar to yourbucketname.s3-external-3.amazonaws.com AFAIR). I think this is a quite elegant solution.
Note that $exception->code often the HTTP error code (if available), and $exception->errorCode contains the Amazon-specific code (if available): http://docs.amazonwebservices.com/AmazonS3/2006-03-01/ErrorCodeList.html
IMO - since the game is called REST people should be aware of this themselves. The list of errors is pretty standardized and I see no real reason aside from lazyness ;-)) for the programmer to double the information in your class? I don't follow you. How am I doubling the information?
Not that there isn't a 1-1 mapping between Amazon error codes and HTTP error codes.
So $e->getCode() "replies" to the HTTP equivalent and $e->errorCode to Amazon? Yes. For consistance I should probably rename $e->errorCode to $e->getAmazonErrorCode().
Christian

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