Should I be able to use multiple `GracefulErrorAda...
# hamilton-help
s
Should I be able to use multiple
GracefulErrorAdapter
's in this way? I'd like to be able to catch multipleexceptions in this way. It is currently not working as expected.
Copy code
from selenium.common.exceptions import WebDriverException, TimeoutException

dr = (
    driver.Builder()
    .with_modules(dataflow)
    .with_adapters([
        base.PandasDataFrameResult(),
        GracefulErrorAdapter(
            error_to_catch=WebDriverException,
            sentinel_value=pd.DataFrame() 
        ),
        GracefulErrorAdapter(
            error_to_catch=TimeoutException,
            sentinel_value=pd.DataFrame() 
        )
    ])
    .build()
)
s
@Seth Stokes 🤔 hadn't thought to use it that way. If the sentinel is the same, then you can just pass in a tuple of exceptions. E.g. this should just work:
Copy code
dr = (
    driver.Builder()
    .with_modules(dataflow)
    .with_adapters([
        base.PandasDataFrameResult(),
        GracefulErrorAdapter(
            error_to_catch=(WebDriverException, TimeoutException),
            sentinel_value=pd.DataFrame() 
        )
    ])
    .build()
)
👍 1
e
sentinel
really shouldn't be used like that IMO -- it's very odd. Sentinel value is just an object to pass around that we can compare for equality and that will be unique. It defaults to some preset object IIRC. So you should use the standard sentinel. We have not allowed for multiple adapters -- I think tuples should work? @Stefan Krawczyk that's clever if it does, it's a cool approach
s
@Elijah Ben Izzy right, yes, the actual sentinel value could be the issue here. I was solving for specifying the adapter only once.
s
Ok thanks for the tuple idea. Makes sense on the sentinel value, I was just trying to skip a step
Also, I didn’t realize but I had to
*splat
the list of adapters. It didn’t raise any error, but that what it took for the adapter to work
👍 1