TimeZoneNotFoundException 생성자

정의

TimeZoneNotFoundException 클래스의 새 인스턴스를 초기화합니다.

오버로드

TimeZoneNotFoundException()

시스템 제공 메시지를 사용하여 TimeZoneNotFoundException 클래스의 새 인스턴스를 초기화합니다.

TimeZoneNotFoundException(String)

지정된 메시지 문자열을 사용하여 TimeZoneNotFoundException 클래스의 새 인스턴스를 초기화합니다.

TimeZoneNotFoundException(SerializationInfo, StreamingContext)
사용되지 않음.

serialize된 데이터로부터 TimeZoneNotFoundException 클래스의 새 인스턴스를 초기화합니다.

TimeZoneNotFoundException(String, Exception)

지정된 오류 메시지와 해당 예외의 원인인 내부 예외에 대한 참조를 사용하여 TimeZoneNotFoundException 클래스의 새 인스턴스를 초기화합니다.

TimeZoneNotFoundException()

Source:
TimeZoneNotFoundException.cs
Source:
TimeZoneNotFoundException.cs
Source:
TimeZoneNotFoundException.cs

시스템 제공 메시지를 사용하여 TimeZoneNotFoundException 클래스의 새 인스턴스를 초기화합니다.

public:
 TimeZoneNotFoundException();
public TimeZoneNotFoundException ();
Public Sub New ()

설명

클래스의 매개 변수가 없는 생성자입니다 TimeZoneNotFoundException . 이 생성자는 새 instance 속성을 "표준 시간대 'timeZoneName'이 로컬 컴퓨터에서 찾을 수 없습니다."와 같이 오류를 설명하는 시스템 제공 메시지로 초기화 Message 합니다. 이 메시지는 현재 시스템 문화권에 대해 지역화됩니다.

적용 대상

TimeZoneNotFoundException(String)

Source:
TimeZoneNotFoundException.cs
Source:
TimeZoneNotFoundException.cs
Source:
TimeZoneNotFoundException.cs

지정된 메시지 문자열을 사용하여 TimeZoneNotFoundException 클래스의 새 인스턴스를 초기화합니다.

public:
 TimeZoneNotFoundException(System::String ^ message);
public TimeZoneNotFoundException (string? message);
public TimeZoneNotFoundException (string message);
new TimeZoneNotFoundException : string -> TimeZoneNotFoundException
Public Sub New (message As String)

매개 변수

message
String

예외를 설명하는 문자열입니다.

설명

문자열이 message 속성에 Message 할당됩니다. 문자열은 현재 문화권에 대해 지역화되어야 합니다.

적용 대상

TimeZoneNotFoundException(SerializationInfo, StreamingContext)

Source:
TimeZoneNotFoundException.cs
Source:
TimeZoneNotFoundException.cs
Source:
TimeZoneNotFoundException.cs

주의

This API supports obsolete formatter-based serialization. It should not be called or extended by application code.

serialize된 데이터로부터 TimeZoneNotFoundException 클래스의 새 인스턴스를 초기화합니다.

protected:
 TimeZoneNotFoundException(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
protected TimeZoneNotFoundException (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
[System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
protected TimeZoneNotFoundException (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
new TimeZoneNotFoundException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> TimeZoneNotFoundException
[<System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
new TimeZoneNotFoundException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> TimeZoneNotFoundException
Protected Sub New (info As SerializationInfo, context As StreamingContext)

매개 변수

info
SerializationInfo

serialize된 데이터가 들어 있는 개체입니다.

context
StreamingContext

serialize된 데이터가 들어 있는 스트림입니다.

특성

예외

info 매개 변수가 null인 경우

또는

context 매개 변수가 null인 경우

설명

이 생성자는 개체를 인스턴스화 TimeZoneNotFoundException 하기 위해 코드에서 직접 호출되지 않습니다. 대신 스트림에서 개체를 IFormatter 역직렬화 TimeZoneNotFoundException 할 때 개체의 Deserialize 메서드에 의해 호출됩니다.

적용 대상

TimeZoneNotFoundException(String, Exception)

Source:
TimeZoneNotFoundException.cs
Source:
TimeZoneNotFoundException.cs
Source:
TimeZoneNotFoundException.cs

지정된 오류 메시지와 해당 예외의 원인인 내부 예외에 대한 참조를 사용하여 TimeZoneNotFoundException 클래스의 새 인스턴스를 초기화합니다.

public:
 TimeZoneNotFoundException(System::String ^ message, Exception ^ innerException);
public TimeZoneNotFoundException (string? message, Exception? innerException);
public TimeZoneNotFoundException (string message, Exception innerException);
new TimeZoneNotFoundException : string * Exception -> TimeZoneNotFoundException
Public Sub New (message As String, innerException As Exception)

매개 변수

message
String

예외를 설명하는 문자열입니다.

innerException
Exception

현재 예외의 원인인 예외입니다.

예제

다음 예제에서는 을 throw하는 존재하지 않는 표준 시간대를 검색하려고 합니다 TimeZoneNotFoundException. 예외 처리기는 예외 처리기가 호출자에게 반환하는 새 TimeZoneNotFoundException 개체에서 예외를 래핑합니다. 그런 다음 호출자의 예외 처리기는 외부 및 내부 예외에 대한 정보를 표시합니다.

private void HandleInnerException()
{   
   string timeZoneName = "Any Standard Time";
   TimeZoneInfo tz;
   try
   {
      tz = RetrieveTimeZone(timeZoneName);
      Console.WriteLine("The time zone display name is {0}.", tz.DisplayName);
   }
   catch (TimeZoneNotFoundException e)
   {
      Console.WriteLine("{0} thrown by application", e.GetType().Name);
      Console.WriteLine("   Message: {0}", e.Message);
      if (e.InnerException != null)
      {
         Console.WriteLine("   Inner Exception Information:");
         Exception innerEx = e.InnerException;
         while (innerEx != null)
         {
            Console.WriteLine("      {0}: {1}", innerEx.GetType().Name, innerEx.Message);
            innerEx = innerEx.InnerException;
         }
      }            
   }   
}

private TimeZoneInfo RetrieveTimeZone(string tzName)
{
   try
   {
      return TimeZoneInfo.FindSystemTimeZoneById(tzName);
   }   
   catch (TimeZoneNotFoundException ex1)
   {
      throw new TimeZoneNotFoundException( 
            String.Format("The time zone '{0}' cannot be found.", tzName), 
            ex1);
   }          
   catch (InvalidTimeZoneException ex2)
   {
      throw new InvalidTimeZoneException( 
            String.Format("The time zone {0} contains invalid data.", tzName), 
            ex2); 
   }      
}
open System

let retrieveTimeZone tzName =
    try
        TimeZoneInfo.FindSystemTimeZoneById tzName
    with 
    | :? TimeZoneNotFoundException as ex1 ->
        raise (TimeZoneNotFoundException($"The time zone '{tzName}' cannot be found.", ex1) )
    | :? InvalidTimeZoneException as ex2 ->
        raise (InvalidTimeZoneException($"The time zone {tzName} contains invalid data.", ex2) )

let handleInnerException () =
    let timeZoneName = "Any Standard Time"
    try
        let tz = retrieveTimeZone timeZoneName
        printfn $"The time zone display name is {tz.DisplayName}."
    with :? TimeZoneNotFoundException as e ->
        printfn $"{e.GetType().Name} thrown by application"
        printfn $"   Message: {e.Message}" 
        if e.InnerException <> null then
            printfn "   Inner Exception Information:"
            let rec printInner (innerEx: exn) =
                if innerEx <> null then
                    printfn $"      {innerEx.GetType().Name}: {innerEx.Message}"
                    printInner innerEx.InnerException
            printInner e
Private Sub HandleInnerException()
   Dim timeZoneName As String = "Any Standard Time"
   Dim tz As TimeZoneInfo
   Try
      tz = RetrieveTimeZone(timeZoneName)
      Console.WriteLine("The time zone display name is {0}.", tz.DisplayName)
   Catch e As TimeZoneNotFoundException
      Console.WriteLine("{0} thrown by application", e.GetType().Name)
      Console.WriteLine("   Message: {0}", e.Message)
      If e.InnerException IsNot Nothing Then
         Console.WriteLine("   Inner Exception Information:")
         Dim innerEx As Exception = e.InnerException
         Do
            Console.WriteLine("      {0}: {1}", innerEx.GetType().Name, innerEx.Message)
            innerEx = innerEx.InnerException
         Loop While innerEx IsNot Nothing
      End If            
   End Try   
End Sub

Private Function RetrieveTimeZone(tzName As String) As TimeZoneInfo
   Try
      Return TimeZoneInfo.FindSystemTimeZoneById(tzName)
   Catch ex1 As TimeZoneNotFoundException
      Throw New TimeZoneNotFoundException( _
            String.Format("The time zone '{0}' cannot be found.", tzName), _
            ex1) 
   Catch ex2 As InvalidTimeZoneException
      Throw New InvalidTimeZoneException( _
            String.Format("The time zone {0} contains invalid data.", tzName), _
            ex2) 
   End Try      
End Function

설명

일반적으로 이 TimeZoneNotFoundException 오버로드를 사용하여 에서 예외를 처리합니다.trycatch 블록. 매개 변수는 innerException 블록에서 catch 처리되는 예외 개체에 대한 참조이거나 일 수 있습니다 null. 그런 다음 이 값은 개체의 InnerException 속성에 TimeZoneNotFoundException 할당됩니다.

문자열이 message 속성에 Message 할당됩니다. 문자열은 현재 문화권에 대해 지역화되어야 합니다.

적용 대상