YAML::Syck fault tolerance

P

Phlip

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?
 
J

Jan Svitok

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)
 
P

Phlip

Jan said:
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...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top