본문 바로가기
VB.net

오류 확인 로직_테스트중

by 호야호잇 2020. 9. 23.

LOAD 아래 입력

 

' Get your application's application domain for error handling.

Dim currentDomain As AppDomain = AppDomain.CurrentDomain

' Define a handler for unhandled exceptions.

AddHandler currentDomain.UnhandledException, AddressOf MYExnHandler

' Define a handler for unhandled exceptions for threads behind forms.

AddHandler Application.ThreadException, AddressOf MYThreadHandler

 

아래 함수 추가

 

Private Sub MYExnHandler(ByVal sender As Object, ByVal e As UnhandledExceptionEventArgs)

Dim EX As Exception

EX = e.ExceptionObject

If EX.StackTrace.Contains("SOMETHING") Then

My.Computer.FileSystem.WriteAllText(LogToWrite, "Error SOMETHING caught:" & EX.StackTrace & vbCrLf, True, System.Text.Encoding.Default)

MsgBox("error caught. Contact **XXX** for assistance!" & vbCrLf & vbCrLf & "Error: " & vbCrLf & EX.StackTrace,, "Fatal Error")

End If

End Sub

 

Private Sub MYThreadHandler(ByVal sender As Object, ByVal e As Threading.ThreadExceptionEventArgs)

If e.Exception.StackTrace.Contains("SOMETHING") Then

My.Computer.FileSystem.WriteAllText(LogToWrite, "Error SOETHING caught:" & e.Exception.StackTrace & vbCrLf, True, System.Text.Encoding.Default)

MsgBox("Error caught. Contact **xxx** for assistance!" & vbCrLf & vbCrLf & "Error: " & vbCrLf & e.Exception.StackTrace,, "Fatal Error")

End If

End Sub

 

'VB.net' 카테고리의 다른 글

윤달 체크 로직  (0) 2020.09.28
전역 오류 확인 및 전달 로직  (0) 2020.09.24
네이버 OpenAPI 이용한 Shorten URL  (0) 2020.05.29
프로세스 확인  (0) 2020.05.08
중복값 제거 방법 (List 이용)  (0) 2020.04.07