tools: Fix error handling.