Thrown errors are always of type unknown, so you have to assert them back into a known type.
Or throw caution to the wind and arbitrarily cast them to a type of your choosing, but that never ends well. A robust and maintainable system can’t reasonably do that.