Skip to content

New name and semantics for Bug (was BadArgument)

Ian Jackson requested to merge Diziet/arti:error-kind-badargument into main

The existing BadArgument always represents a bug, perhaps in Arti or perhaps in its caller/embedder.

But the highest-level code is not interested in precisely what the nature of such a bug is. IMO we don't want a separate kind for "bad parameter" vs "called things in wrong order" (for example). So here I rename it.

As discussed in the docs (as amended here), the distinction between EK::Internal and EK::BadAPIUsage is that Internal is known to be a bug in Arti, whereas BadAPIUsage might be in Arti or (more usually) in the caller. I don't personally think this is a particularly useful distinction, but during our previous discussions I understood both @nickm and @eta to want to distinguish "definitely a bug in Arti", and I don't object to that. (We can never be sure that something is a bug in the caller, since a bug in Arti might wrongly attribute an error to the caller, so there are only these two cases, not three.)

IMO an error with kind BadAPIUsage should (almost?) always contain a stack trace for the same reasons as InternalError does. Here, I achieve this by having a single Bug error type which has a kind field.

(See also ProtocolViolation, which can represent a bug on the same machine but in a different process.)

Edited by Ian Jackson

Merge request reports

Loading