[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

YAML::Syck fault tolerance

Phlip

1/19/2007 11:07:00 PM

Ruboids:

I need to read a block of YAML and recover gracefully if it fails. The
current loader apparently throws away all the representation it loaded at
error time.

Is there some way to get the representation loaded before the error
happens?

--
Phlip
2 Answers

Jano Svitok

1/21/2007 11:38:00 AM

0

On 1/20/07, Phlip <phlip2005@nogmailspam.com> wrote:
> Ruboids:
>
> I need to read a block of YAML and recover gracefully if it fails. The
> current loader apparently throws away all the representation it loaded at
> error time.
>
> Is there some way to get the representation loaded before the error
> happens?

Not tested idea: If the exception contains error position, try cutting
the string just before the error and retry... (althoug this won't be a
stable solution, it's more a hack)

Phlip

1/21/2007 4:43:00 PM

0

Jan Svitok wrote:

> Not tested idea: If the exception contains error position, try cutting
> the string just before the error and retry... (althoug this won't be a
> stable solution, it's more a hack)

That's what I hacked-in shortly after posting. The actual bug was something
truncated a database BLOB containing the YAML. The hack works for
stereotypical YAML with one line per record...

Architecturally, and only for curiosity, I have heard there's an XML system
called SAX that calls a callback for each node it reads. If a YAML system
could do that, I could collect the nodes up to the break point, then I
wouldn't need to worry about the hack...

--
Phlip
http://www.greencheese.u... <-- NOT a blog!!!