scd: Improve error handling.