Improve error handling in legacy extension