Skip to content

Provide examples of using WindowsError and SystemError in the docs #54

Closed

Description

@vitaut

Provide 2-3 examples of real Windows error codes in the example so its usage makes sense and mention what happens if you enter a code that is not an official error code.

Activity

  1. patlecat commented on Jul 9, 2014

    @patlecat

    Okay as discussed, here my example code that will let the user run through the Windows error codes by using the C++11 random generators - because rand() must not be used anymore!
    Here's the list btw: http://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs.85).aspx

       #include <chrono>
       #include <random>
    
       unsigned long ulError = GetLastError(); // Get the error in this way
    
       // Setup the random number generator
        unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
        std::default_random_engine generator(seed);
        std::uniform_int_distribution<unsigned short> distribution (0, 15999); // Range of the Windows Error Codes
        unsigned short rand_error = distribution (generator);
    
        fmt::WindowsError gimmError (rand_error, " TestError: ");
        cerr << "\n***ERROR (" << rand_error << ")" << gimmError.what();

    Output if you enter a number that is not a Windows error code: ***ERROR (6449) TestError: error code = 6449

  2. vitaut commented on Jul 9, 2014

    @vitaut
    ContributorAuthor

    Thanks!

  3. vitaut commented on Feb 6, 2015

    @vitaut
    ContributorAuthor

    Added examples, but still need to clarify what happens if you pass an invalid error code.

  4. vitaut commented on Feb 7, 2015

    @vitaut
    ContributorAuthor

    Fixed in 326ade7.

  5. vitaut commented on Feb 7, 2015

    @vitaut
    ContributorAuthor

    Took me only 7 months to close this =)

  6. patlecat commented on Feb 9, 2015

    @patlecat

    Cool 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions