Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6537191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:35:14+00:00 2026-05-25T10:35:14+00:00

I have a driver for a remote device, and the driver communicates with the

  • 0

I have a driver for a remote device, and the driver communicates with the device via socket. The driver has properties that clients can use to get information about the device. Every property uses the driver’s private read/write method to send a query to the device and wait for a response.

I’m trying to determine the best way to handle socket exceptions. Specifically, when the client uses one of the properties to get information about the device, I have to rethrow exceptions that occur in the read/write method, otherwise, the client would receive a default value, without knowing something went wrong.

Are there any design patterns or common approaches to this type of issue? It seems a bit tedious to handle exceptions anytime a client uses the driver properties. But then again, the only work around I see is to have a boolean HasError property on the driver. This is really just an indirect workaround to actually throwing an exception and having the client catch it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T10:35:15+00:00Added an answer on May 25, 2026 at 10:35 am

    You should interpret the socket exceptions and rethrow something more informative for the client: they don’t want to have to think about socket problems. If your exceptions don’t map onto any existing exceptions very well, create your own exception type and return informative messages such as “there is a problem with the network connection” rather then something like “socket read error”.

    e.g.

    try {
       tcpClient = new TcpClient(address.ToString(), port);
    } catch (SocketException SE) {
       throw new MyDriverException("Failed to connect to remote device");
    }
    

    You could of course add some details from the SocketException to your own message for debugging purposes.

    Exceptions are still definitely the way to go, but you want to give your client meaningful messages in their context, rather than yours. After all, when you use the socket classes you get SocketExceptions: not NDIS exceptions or whatever, which would mean nothing to you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a driver that my company has been using for a few years
I have a device driver I want to patch. This device driver calls IOLog
I have a C++ driver I'm trying to compile, and it has this line
something driver me crazy here i have a big HTML template which i can't
I have established a link using Netbeans and Paradox driver and can query the
I have the following PL/SQL being sent to a remote oracle 11gr2 server via
I have been digging internet for couple days, reading very old information, that leads
I have JDBC driver dependencies (e.g. h2, mysql ..) which have to be copied
After much fiddling, I've managed to install the right ODBC driver and have successfully
I have a kernel service driver , i want to install it with an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.