Fixes #5444: correct the error classes used