Fix error handling in resource_tree