Debug.Fail 메서드

정의

오류 메시지를 내보냅니다.

오버로드

Fail(String, String)

오류 메시지와 자세한 오류 메시지를 내보냅니다.

Fail(String)

지정된 오류 메시지를 내보냅니다.

Fail(String, String)

Source:
Debug.cs
Source:
Debug.cs
Source:
Debug.cs

오류 메시지와 자세한 오류 메시지를 내보냅니다.

public:
 static void Fail(System::String ^ message, System::String ^ detailMessage);
[System.Diagnostics.Conditional("DEBUG")]
public static void Fail (string message, string detailMessage);
[System.Diagnostics.Conditional("DEBUG")]
public static void Fail (string? message, string? detailMessage);
[<System.Diagnostics.Conditional("DEBUG")>]
static member Fail : string * string -> unit
Public Shared Sub Fail (message As String, detailMessage As String)

매개 변수

message
String

내보낼 메시지입니다.

detailMessage
String

내보낼 자세한 메시지입니다.

특성

예제

다음 예제에서는 메서드를 Fail 사용하여 예외 처리 중에 메시지를 출력합니다.

catch ( Exception^ e ) 
{
   #if defined(DEBUG)
   Debug::Fail( "Cannot find SpecialController, proceeding with StandardController", "Setting Controller to default value" );
   #endif
}
catch (Exception)
{
    Debug.Fail("Invalid value: " + value.ToString(),
       "Resetting value to newValue.");
    value = newValue;
}
Catch e As Exception
    Debug.Fail("Invalid value: " + value.ToString(), "Resetting value to newValue.")
    value = newValue
End Try

switch 문에서 메서드를 Fail 사용할 수도 있습니다.

   switch ( option )
   {
      case Option::First:
         result = 1.0;
         break;

      // Insert additional cases.
      
      default:
         #if defined(DEBUG)
         Debug::Fail( "Unknown Option" + option, "Result set to 1.0" );
         #endif
         result = 1.0;
         break;
   }
switch (option1)
{
    case MyOption.First:
        result = 1.0;
        break;

    // Insert additional cases.

    default:
        Debug.Fail("Unknown Option " + option1, "Result set to 1.0");
        result = 1.0;
        break;
}
Select Case option1
    Case MyOption.First
        result = 1.0
    
    ' Insert additional cases.
    Case Else
        Debug.Fail("Unknown Option " & option1, "Result set to 1.0")
        result = 1.0
End Select

설명

기본 동작을 DefaultTraceListener 애플리케이션 및 사용자 인터페이스 모드로 실행 중일 때 메시지 상자에 메시지를 출력 합니다 TraceListener 인스턴스는 Listeners 컬렉션.

참고

메시지 상자의 표시는 의 존재 DefaultTraceListener에 따라 달라집니다. 가 DefaultTraceListener 컬렉션에 Listeners 없으면 메시지 상자가 표시되지 않습니다. 는 DefaultTraceListenerclear>, remove 또는 속성()에서 메서드를 호출하여 제거할<>수 있습니다.<ClearListenersSystem.Diagnostics.Trace.Listeners.Clear()

컬렉션에 을 TraceListener 추가하거나 컬렉션에서 Listeners 제거하여 이 동작을 사용자 지정할 수 있습니다.

추가 정보

적용 대상

Fail(String)

Source:
Debug.cs
Source:
Debug.cs
Source:
Debug.cs

지정된 오류 메시지를 내보냅니다.

public:
 static void Fail(System::String ^ message);
[System.Diagnostics.Conditional("DEBUG")]
public static void Fail (string message);
[System.Diagnostics.Conditional("DEBUG")]
public static void Fail (string? message);
[<System.Diagnostics.Conditional("DEBUG")>]
static member Fail : string -> unit
Public Shared Sub Fail (message As String)

매개 변수

message
String

내보낼 메시지입니다.

특성

예제

다음 예제에서는 메서드를 Fail 사용하여 예외 처리 중에 메시지를 출력합니다.

catch ( Exception^ e ) 
{
   #if defined(DEBUG)
   Debug::Fail( "Unknown Option " + option + ", using the default." );
   #endif
}
catch (Exception)
{
    Debug.Fail("Unknown Option " + option + ", using the default.");
}
Catch e As Exception
    Debug.Fail("Unknown Option " + myOption1 + ", using the default.")
End Try

switch 문에서 메서드를 Fail 사용할 수도 있습니다.

   switch ( option )
   {
      case Option::First:
         result = 1.0;
         break;

      // Insert additional cases.
      
      default:
         #if defined(DEBUG)
         Debug::Fail( "Unknown Option" + option );
         #endif
         result = 1.0;
         break;
   }
switch (option)
{
    case Option.First:
        result = 1.0;
        break;

    // Insert additional cases.

    default:
        Debug.Fail("Unknown Option " + option);
        result = 1.0;
        break;
}
Select Case myOption1
    Case MyOption.First
        result = 1.0
    
    ' Insert additional cases.
    Case Else
        Debug.Fail(("Unknown Option " & myOption1.ToString))
        result = 1.0
End Select

설명

기본 동작을 DefaultTraceListener 애플리케이션 및 사용자 인터페이스 모드로 실행 중일 때 메시지 상자에 메시지를 출력 합니다 TraceListener 인스턴스는 Listeners 컬렉션.

참고

메시지 상자의 표시는 의 존재 DefaultTraceListener에 따라 달라집니다. 가 DefaultTraceListener 컬렉션에 Listeners 없으면 메시지 상자가 표시되지 않습니다. 는 DefaultTraceListenerclear>, remove 또는 속성()에서 메서드를 호출하여 제거할<>수 있습니다.<ClearListenersSystem.Diagnostics.Trace.Listeners.Clear()

컬렉션에 을 TraceListener 추가하거나 컬렉션에서 Listeners 제거하여 이 동작을 사용자 지정할 수 있습니다.

추가 정보

적용 대상