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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:00:22+00:00 2026-05-26T13:00:22+00:00

Some Windows functions such as CreateFile could return a huge variety of error codes

  • 0

Some Windows functions such as CreateFile could return a huge variety of error codes when GetLastError is called, and it’s impractical to check for every possible error code — there is often not enough documentation, and new error codes are added frequently.

Some of them (such as access violations or invalid parameters) are due to programmer error and should not allow continuation of program execution. However, others are due to other factors, such as bad file permissions, sharing violations, bad file names, etc., which the developer has little or no control over.

I would like to handle all “non-critical” errors (such as bad file names), while allowing “critical errors” (such as access violations) to crash my program.

Ideally, I would be saying:

// ... an error occurred. Is it a programmer error?

if (IsErrorCritical(GetLastError()))
{
    // Yes; raise an exception, crashing the program.
    RaiseException(GetLastError(), 0, 0, NULL);
}

How do I decide which error codes are safe to suppress (for example, when enumerating files on a disk), when I cannot possibly predict each and every outcome?

  • 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-26T13:00:22+00:00Added an answer on May 26, 2026 at 1:00 pm

    I think it really depends on the context, it is impossible to generally decide this instead it needs to be decided on a case by case basis.

    The reason I say this is that sometimes the same error code comes in different contexts so its not the error code itself that can be used to determine if it is critical but the context itself.

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

Sidebar

Related Questions

I'm messing around with some windows functions using p/invoke. Occasionally, I get an error
I'm porting some crufty C++ Windows-code to Linux, which uses functions called open and
Under Windows there are some handy functions like QueryPerformanceCounter from mmsystem.h to create a
I'm using Windows API's CreateFile and SetCommState functions to open a number of serial
I need to use Windows7.DesktopIntegration.WindowsFormsExtensions functions, such as WindowsFormsExtensions.SetTaskbarProgress, with some opened forms. These
I need to use some functions from the Win32 Crypto API, such as CryptQueryObject.
This is a Windows Forms application. I have a function which captures some mouse
Some Windows native applications have a question mark icon on the title bar. It's
Some Windows applications add buttons to the control box, which apparently is the name
Suppose some Windows service uses code that wants mapped network drives and no UNC

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.