How to handle dangling references to deleted records

and

I know you were asking for a way to handle this without handling the exception but this is what I do when an exception is ‘too broad’:

try:
    blah.cause_table_error()
except anvil.tables.TableError as err:
    if "This row has been deleted" in str(err):
        handle_exception_whatever()
    else:
        # or pass #or nothing
        # or print(str(err)) #whatever
        raise

ymmv, if there are an abundance of errors this could get slow.

1 Like