Ignore:
Timestamp:
Aug 21, 2008, 11:01:02 AM (16 years ago)
Author:
イグトランス (egtra)
Message:

Exception.ToStringでHRESULTをFormatMessageで文字列化したものを出力するようにした(要#192)。

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ab5.0/ablib/src/Classes/System/Exception.ab

    r559 r602  
    3333InvalidProgramException
    3434MemberAccessException
    35     FieldAccessException 
    36     MethodAccessException 
    37     MissingMemberException 
     35    FieldAccessException
     36    MethodAccessException
     37    MissingMemberException
    3838MulticastNotSupportedException
    3939NullReferenceException
     
    9999    */
    100100    Override Function ToString() As String
    101         If Object.ReferenceEquals(toStr, Nothing) Then
     101        Imports ActiveBasic.Strings.Detail
     102        If ActiveBasic.IsNothing(toStr) Then
    102103            Dim sb = New System.Text.StringBuilder
    103             sb.Append(GetType().FullName).Append(": ")
    104             sb.Append(Message)
    105             toStr = sb.ToString
     104            With sb
     105                .Append(GetType().FullName).Append(": ")
     106                .Append(Message)
     107                .Append(" (Error code: ")
     108                .Append(FormatIntegerX(hr As DWord, 8, 0, BPrefix))
     109                Dim s = ActiveBasic.Windows.HResultToString(hr)
     110                If Not String.IsNullOrEmpty(s) Then
     111                    .Append(" ").Append(s)
     112                End If
     113                .Append(")")
     114                toStr = .ToString
     115            End With
    106116        End If
    107117        Return toStr
Note: See TracChangeset for help on using the changeset viewer.