Error handling for readResource