Use this when designing how each step handles failure.
Error Handling · Automation Design
Error handling in automation design decides upfront how each step reacts to failure — stop, retry, skip or compensate — and ensures errors are logged with enough context to fix them.
1. Handle errors explicitly: catch, log with context, clean up, return failure.
2. Don't swallow errors.
3. Distinguish retryable and fatal.
4. Rollback when needed.
5. Alert owners.
error → classify → handle/rollback → report
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Common mistakes Narrow the fault
- Bare
except:that hides errors. ignore_errors: trueon tasks that matter.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- Decide per step whether to stop, retry, skip or compensate.
- Every error log must name the step, target and cause.
- After a failure the system must be in a known state.
- Try/except or block/rescue in code — handling
- Error messages with context — diagnostics
- Non-zero exit on failure — signal
ReferenceWhy it matters1 section · depth on demand
What it is
Error handling decides what happens when a step fails: stop, retry, skip, or roll back. Every external call should have a timeout and a defined error path, and errors should be reported with enough context to act on.
ReferenceImportant terms & boundaries2 sections · depth on demand
Example
try:
r = requests.get(url, timeout=10)
r.raise_for_status()
except requests.RequestException as exc:
log.error("inventory fetch failed: %s", exc)
sys.exit(2)
In depth
Error handling decides what an automation does when a step does not go as planned: stop, retry, skip, roll back or alert. The worst outcome is the silent one — a step fails, the script carries on, and later steps act on a broken state. Good error handling makes every failure visible and leaves the system in a known state.
Design rules:
- Fail by default; continue only where a failure is explicitly harmless.
- Distinguish transient errors (timeouts, rate limits — retry) from permanent ones (bad input, permission denied — stop).
- Report the step, target, input and error message, not just "failed".
- Clean up partial work, or record exactly what was left behind.
set -euo pipefail
trap 'echo "Failed at line $LINENO: $BASH_COMMAND" >&2' ERR
try:
push_config(device)
except TimeoutError:
retry_later(device)
except PermissionError as e:
log.error("auth failed on %s: %s", device, e); raise
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Automation Design > Error Handling. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://learn.microsoft.com/en-us/azure/well-architected/operational-excellence/enable-automation · confidence 94%