edgi-govdata-archiving / wayback

A Python API to the Internet Archive Wayback Machine
https://wayback.readthedocs.io/en/stable/
BSD 3-Clause "New" or "Revised" License
61 stars 12 forks source link

Add `MementoOutsideWindow` Exception #54

Open Mr0grog opened 3 years ago

Mr0grog commented 3 years ago

Running into and fixing #53 reminded me that we don’t have a specific error for the situation where a memento can be served, but from a time that is beyond the specified target_window parameter. Instead, we currently just raise a fairly generic MementoPlaybackError.

We also have a TODO in the code that references this: https://github.com/edgi-govdata-archiving/wayback/blob/c066e04c1ba11c26febac574b37ee739cc5796e2/wayback/exceptions.py#L32-L40

I’m thinking MementoOutsideWindow, MementoOutOfWindow, or MementoOutOfRange are good candidates for names here. “Range” feels like more traditional wording, but doesn’t clearly match up with the parameter that causes it, which is “target_window.” We could also change the parameter name to “targetrange.” ¯\_(ツ)\

Regardless of the name, it should be a subclass of MementoPlaybackError.

Mr0grog commented 3 years ago

It would also be great if we could include info about the actual Memento’s timestamp and the specified target window, so calling code can make decisions based on or display info about how far off a viable memento might be.