Improve error reporting

Follow-up of changes introduced in commit 72c922668fefc1cf671d9c9e38ebf22a22a80dcf