summaryrefslogtreecommitdiffstats
path: root/ds9/library/error.tcl
blob: 6abcd31ee5505d874b62834615e2ccc79ef043f9 (plain)
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
63
64
65
66
67
68
69
70
71
72
73
#  Copyright (C) 1999-2017
#  Smithsonian Astrophysical Observatory, Cambridge, MA, USA
#  For conditions of distribution and use, see copyright notice in "copyright"

package provide DS9 1.0

# capture general errors
# this only captures gui errors, not xpa errors
proc bgerror {err} {
    tk_messageBox -type ok -icon error \
	-message "[msgcat::mc {An internal error has been detected}] $err"
}

# force capture xpa/samp/hv/interactive errors
proc InitError {which} {
    global ds9
    set ds9(msg) {}
    set ds9(msg,level) info
    set ds9(msg,src) $which

    global errorInfo
    set errorInfo {}
}

proc Info {message} {
    ProcessMessage info $message
}

proc Warning {message} {
    ProcessMessage warning $message
}

# used by backup
proc Error {message} {
    ProcessMessage error $message
}

proc ProcessMessage {level message} {
    global ds9
    global pds9

    set ds9(msg,level) $level
    switch -- $ds9(msg,src) {
	xpa -
	hv -
	samp {set ds9(msg) $message}
	default {
	    if {$pds9(confirm)} {
		tk_messageBox -message $message -type ok -icon $level
	    }
	}
    }
}

# here is where errors from within the canvas widgets 
# will try to get our attention. 
# XPA, HV, and SAMP will have already seen any problems
proc ErrorTimer {} {
    global ds9
    global pds9

    if {$ds9(msg) != {}} {
	if {$pds9(confirm)} {
	    tk_messageBox -message $ds9(msg) -type ok -icon $ds9(msg,level)
	}
	InitError tcl
    }

    # set again
    after $ds9(msg,timeout) ErrorTimer
}