www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Bug in Registry.d

reply "dickl" <dick221z yahoo.com> writes:
I'm try to rebuild phobos with debug info.
Got the error in registry.d
std\windows\registry.d(972): no property 'message' for type
'RegistryException'

the code is as follows:
----------------
catch(RegistryException x)
{
    assert(x.error == code);
    if(string != x.toString())
    {
    printf( "UnitTest failure for RegistryException:\n"
    " x.message[%d;\"%.*s\"] does not equal [%d;\"%.*s\"]\n"
    , x.message.length, x.message
    , string.length, string);
    }
    assert(message == x.msg);
}

-------------
Since RegistryException is ultimately derived from Exception, this class has
the variable called msg not message.
So x.message needs to be changed to x.msg
May 07 2004
parent "Matthew" <matthew.hat stlsoft.dot.org> writes:
This is because I'd developed, and submitted to Walter, the class Win32Exception
in a separate file - std/windows/exceptions.d -  and he appears to have defined
his own, erroneously simplified, version within registry.d, rather than either
incorporating the new file into Phobos, or the full definition into registry.d.

I have no control over either of these, but I expect Walter'll fix it up next
time.

For the moment, you might just change Win32Exception in registry.d to the
following:

    /// This class is the root exception class for Win32, and provides
mechanisms
    /// for representing Win32 error codes and extracting error translation
messages.
    class Win32Exception
        : Exception
    {
    /// \name Construction
    // {
    public:
        /// \brief Creates an instance of the exception
        ///
        /// \param message The message associated with the exception
        this(char[] message)
        {
            this(message, GetLastError());
        }
        /// \brief Creates an instance of the exception, with the given
        ///
        /// \param message The message associated with the exception
        /// \param error The Win32 error number associated with the exception
        this(char[] message, int error)
        {
            char    sz[24]; // Enough for the three " ()" characters and a
64-bit
integer value
            int     cch = wsprintfA(sz, " (%d)", error);

            m_message = message;
            m_error   = error;

            super(message ~ sz[0 .. cch]);
        }
    // }

    /// \name Attributes
    // {
    public:
        /// Returns the message string associated with the exception
        char[] message()
        {
            return m_message;
        }

        /// Returns the Win32 error code associated with the exception
        int error()
        {
            return m_error;
        }

        /// Converts the error code into a string, searching the default system
message libraries
        char[] lookupError()
        {
            return FormatMessage(m_error);
        }

        /// Converts the error code into a string, searching the given message
module
        ///
        /// \note Not yet implemented
        char[] lookupError(char[] moduleName)
        {
            return FormatMessage(m_error, moduleName);
        }
    // }

    /// \name Members
    // {
    private:
        char[]  m_message;
        int     m_error;
    // }
    }


"dickl" <dick221z yahoo.com> wrote in message
news:c7grmo$1g2h$1 digitaldaemon.com...
 I'm try to rebuild phobos with debug info.
 Got the error in registry.d
 std\windows\registry.d(972): no property 'message' for type
 'RegistryException'

 the code is as follows:
 ----------------
 catch(RegistryException x)
 {
     assert(x.error == code);
     if(string != x.toString())
     {
     printf( "UnitTest failure for RegistryException:\n"
     " x.message[%d;\"%.*s\"] does not equal [%d;\"%.*s\"]\n"
     , x.message.length, x.message
     , string.length, string);
     }
     assert(message == x.msg);
 }

 -------------
 Since RegistryException is ultimately derived from Exception, this class has
 the variable called msg not message.
 So x.message needs to be changed to x.msg
May 07 2004