Courseiva

200-901 Software Development and Design Practice Question

A network engineer writes a Python script to handle exceptions when making REST API calls. Which exception type should be caught to handle network connectivity issues (e.g., DNS failure, refused connection)?

⚠ Common exam trap

Cisco often tests the distinction between the broad `RequestException` and the specific `ConnectionError`, trapping candidates who choose the base class thinking it covers all errors, when the question explicitly asks for network connectivity issues.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

requests.exceptions.ConnectionError

`requests.exceptions.ConnectionError` is specifically raised when the underlying TCP connection fails, which includes scenarios like DNS resolution failures, refused connections, or the remote host being unreachable. This exception is a subclass of `RequestException` and directly maps to network-level issues at the transport layer, making it the precise exception to catch for connectivity problems.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    requests.exceptions.RequestException

    Why it's wrong here

    RequestException is the base class for all requests exceptions, so catching it also swallows HTTPError, Timeout and other unrelated failures rather than isolating connectivity faults. It is tempting as a catch-all for any API call failure; however, ConnectionError is the specific subclass raised for DNS failure and refused connections.

  • ✓

    requests.exceptions.ConnectionError

    Why this is correct

    requests.exceptions.ConnectionError is raised when the underlying connection cannot be established, covering DNS resolution failures and refused connections. Catching it satisfies the requirement to handle network connectivity issues, unlike HTTPError, which signals a received error response.

  • ✗

    requests.exceptions.HTTPError

    Why it's wrong here

    HTTPError is raised only when a response returns an unsuccessful status code, so it never fires for DNS failure or refused connections where no response arrives. It is tempting because API scripts commonly check status codes; however, ConnectionError is the subclass that covers those transport-level failures.

  • ✗

    requests.exceptions.Timeout

    Why it's wrong here

    Timeout fires only when a connection or read exceeds the configured timeout, not when DNS resolution fails or a connection is refused outright. It is tempting because slow or unreachable endpoints often manifest as timeouts; however, ConnectionError is the subclass raised for those connectivity faults.

Visual reference

Client Recursive Resolver Root DNS (13 root servers) TLD DNS (.com, .org, …) Authoritative example.com query IP addr answer

About these practice questions

This 200-901 question is part of Courseiva's 975-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This 200-901 practice question is part of Courseiva's free Cisco certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 200-901 exam.