YAML::Syck fault tolerance

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?

On 1/20/07, Phlip [email protected] 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)

Jan S. 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…

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs