On Fri, Oct 09, 2009 at 01:10:40PM +1100, Steven D'Aprano wrote:
> On Thu, 8 Oct 2009 08:18:40 pm Oleg Broytman wrote:
> >    Are you going to parse any garbage and create a Message (probably
> > an empty Message) with one defect "cannot parse it at all"?
> 
> So long as the raw garbage is available for the caller somehow, that 
> seems like a reasonable approach to me. That lets an application 
> display "Unparsable message" to the user, who can then ask to "View 
> Source" (or equivalent) to get access to the raw bytes of the message.

   I don't see any difference with "raise an exception; the calling
application catches the exceptions, displays or logs "Unparseable message",
and displays or logs the original garbage (that can be an attribute of the
exception instance)".
   The difference IFAIU could be between well-formed messages and complete
garbage. A not well-formed input will be parsed to a Message, and such
parsing requires a clever algorithm with resynchronizations (jumps from a
bad point to a recognized good point to restart parsing there). I don't
know if it's possible to create such a clever algorithm; and for complete
unparseable garbage I still prefer an exception.

Oleg.
-- 
     Oleg Broytman            http://phd.pp.ru/            [email protected]
           Programmers don't die, they just GOSUB without RETURN.
_______________________________________________
Email-SIG mailing list
[email protected]
Your options: 
http://mail.python.org/mailman/options/email-sig/archive%40mail-archive.com

Reply via email to