Refs #23: improve error handling