forked from fantaisie-software/purebasic
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathErrorHandler.pb
More file actions
62 lines (47 loc) · 2.02 KB
/
ErrorHandler.pb
File metadata and controls
62 lines (47 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
;--------------------------------------------------------------------------------------------
; Copyright (c) Fantaisie Software. All rights reserved.
; Dual licensed under the GPL and Fantaisie Software licenses.
; See LICENSE and LICENSE-FANTAISIE in the project root for license information.
;--------------------------------------------------------------------------------------------
; Do not use OnError if the real debugger is present (for better debugging)
;
CompilerIf #PB_Compiler_Debugger = 0
ErrorHandler_Called = #False
Goto ErrorHandler_End
ErrorHandler:
If ErrorHandler_Called ; avoid changed calls if something goes wrong in here too
End
EndIf
ErrorHandler_Called = #True
CompilerIf #DEBUG
Message$ = "Error: " + ErrorMessage() + #NewLine
Message$ + "File : " + ErrorFile() + #NewLine
Message$ + "Line : " + Str(ErrorLine()) + #NewLine
CompilerElse
Message$ = "An Error has been detected in the IDE!" + #NewLine
Message$ + "Error: " + ErrorMessage() + #NewLine
If ErrorLine() <> -1
Message$ + "File : " + ErrorFile() + #NewLine
Message$ + "Line : " + Str(ErrorLine()) + #NewLine
EndIf
CompilerEndIf
Message$ + #NewLine
Message$ + "IDE build on " + FormatDate("%mm/%dd/%yyyy [%hh:%ii]", #PB_Compiler_Date) + " by " + #BUILDINFO_User + #NewLine
Message$ + "Branch: " + #BUILDINFO_Branch + " Revision: " + #BUILDINFO_Revision
MessageRequester("Error", Message$, #FLAG_Error)
If (CompilerProgram)
KillProgram(CompilerProgram)
CloseProgram(CompilerProgram)
EndIf
; delete temporary files to not leave them forever
DeleteRegisteredFiles()
CompilerCleanup()
; NOTE: We do not try to save sourcecodes here, as the reason for this
; crash could have also messed them up. Better to loose the recent changes
; than to loose the whole file, because it was corrupted here.
;
; A backup functionality should solve this sometime in the future... :)
End
ErrorHandler_End:
OnErrorGoto(?ErrorHandler)
CompilerEndIf