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

  • Home
  • SEARCH
  • 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 selenium 2 web driver scripts up and running and I now want
I have a web application written in XUL and I've been trying to use
I have a CakePHP site that is working fine (in terms of encoding)...but a
To whom it may respond to, We have installed Oracle 11g r2 on a
I maintain a legacy application that runs on PHP/5.2.6 under Windows Server 2003 and
I need to create a virtual file, a file that if some program access
I have installed SVN and configure eclipse with SVN using subversive plugin. Now i
I have this code and am trying to remove an item from a nested
Hi I have a sqlite db which I am manipulating using qts built in
I've been trying to figure out how to detect this for months without any

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.