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 971057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:54:09+00:00 2026-05-16T02:54:09+00:00

I know that general or across the board exception handling is a big no-no,

  • 0

I know that general or “across the board” exception handling is a big no-no, however I believe that it is okay in this case.

Consider some custom wrapper around BinaryWriter/BinaryReader operations. (Yes, I know of .NET serialization) In all of the methods in this class, there would be the potential to have certain exceptions, like passing in a byte[] that is too short for the data you are trying to read out of it or attempting to read an incorrect type.

So there are all these different methods for writing/reading data and I would like to handle all instances of certain exceptions thrown in this class in a certain way. For example, returning an error state or setting a certain flag whenever an EndOfStreamException is thrown.

Is there a clean/good way to do this short of throwing a try/catch around each read/write operation? Or is this still a big no-no because users of the library should just try-catch the calls to the class themselves?

  • 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-16T02:54:09+00:00Added an answer on May 16, 2026 at 2:54 am

    You could wrap the BinaryWriter/Reader functions in your own object and catch the exceptions there.

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

Sidebar

Related Questions

I know that one can define an 'expected' exception in JUnit, doing: @Test(expect=MyException.class) public
I know that this has already been asked here but the answer (using a
I know about covariance, and I know that in general it will not be
I know that in general, we want to check for the presence of specific
I've just come across some code that's confusing me slightly; there are really 2
I know that one of the big things about Java is that it is
I know that it's a subject that can raise a lot of debate, but
I know that one of the differences between classes and structs is that struct
I know that exceptions have a performance penalty, and that it's generally more efficient
We know that behind the scenes, the ASP.NET MVC framework will use reflection to

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.