raise exceptions
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.3k
- Forks
- 763
- PR merge metrics
- No merged PRs in 30d
Description
At present actions that seem like they would throw exceptions do not. Instead the error is transmitted as part of a data object and the programmer is expected to check for an exception before proceeding.
Example:
for vm in vmList:
if vm.name in vmnames:
if vm.runtime.powerState != vim.VirtualMachinePowerState.poweredOn:
task = vm.PowerOn()
WaitForTasks([task], si)
lease = vm.ExportVm()
if lease.error:
raise lease.error
... this is currently anticipated behavior, so most programmers who have been using the lib for a number of years will have code built to handle this kind of check. The problem is new programmers will expect the method to actually raise an exception (the method's documentation states that it raises exceptions when in pyVmomi it never does).
Enhancement
When an exception occurs on a remote method, raise the exception as if it occurred in Python. This is the most pythonic way to handle raising an exception.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the ExportVm example and trace how a remote method currently returns an object containing error instead of raising it. Compare this behavior with the method documentation, which says exceptions are raised, and identify the remote-method paths that would need consistent handling. Done means remote exceptions are raised as Python exceptions without requiring callers to inspect the returned object.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100