xproc / 3.0-steps

Repository for change requests to the standard step library and for official extension steps
10 stars 7 forks source link

Is err:XC0201 really helpful on p:uncompress? #289

Closed ndw closed 4 years ago

ndw commented 4 years ago

Suppose I uncompress some data. If the resulting stream can be parsed as its content type, good, we're done.

Suppose it can't be parsed. If it can't, then the attempt to parse it must have raised an exception (e.g, err:XD0049). But p:uncompress is required to raise err:XC0201 in this case. That means I'm going to mask the underlying exception.

Pro: the exception you have to catch from p:uncompess is always err:XC0201. Con: catching that exception doesn't tell you anything about what actually failed.

What do folks think?

xml-project commented 4 years ago

Suppose it can't be parsed. If it can't, then the attempt to parse it must have raised an exception (e.g, err:XD0049). But p:uncompress is required to raise err:XC0201 in this case. That means I'm going to mask the underlying exception.

The "masking" seems to be a result of your implementation strategy. In my implementation the parser doesnt generate XProc errrors (like XD0049), but throws eg. a SAXException. My implementation has to catch this and throw XC0201.

In general I would prefer to keep XC0201 because the casting error might not necessarily come from XML parsing. Suppose the uncompressed document claims to be "image/jpeg" and my implementation tests this claim. Currently XC0201 is the error to raise. No other error will fit.

ndw commented 4 years ago

Ok. I don't feel strongly about it. Anyone else have an opinion?

gimsieke commented 4 years ago

I’m with Achim on this one

ndw commented 4 years ago

Okay.