September 27, 2014
https://issues.dlang.org/show_bug.cgi?id=13541

          Issue ID: 13541
           Summary: std.windows.syserror.sysErrorString() should be
                    nothrow
           Product: D
           Version: D2
          Hardware: All
                OS: Windows
            Status: NEW
          Severity: major
          Priority: P1
         Component: Phobos
          Assignee: nobody@puremagic.com
          Reporter: bugzilla@digitalmars.com

It should be nothrow because it is called by constructors like FileException, which are themselves exceptions. Exceptions should be buildable without having "double fault" exceptions happening.

Digging into sysErrorString() there's this:

  if(length == 0)
  {
    throw new Exception(
        "failed getting error string for WinAPI error code: " ~
        sysErrorString(GetLastError()));
  }

This should be an assert because:

1. sysErrorString()'s argument should ONLY be values returned by Windows APIs
like GetLastError(), and so this should always succeed.

2. recursively calling sysErrorString() with the SAME value will cause a stack overflow crash, not any usable exception.

Following this fix, sysErrorString() should be marked as 'nothrow'.

--