Tcl Library Source Code

View Ticket
Login
Ticket UUID: 665fbc24eb7e2726ac0752a5dff02d90894fc6d
Title: error in destructor hides error in constructor
Type: Bug Version: 2.3.2
Submitter: anonymous Created on: 2014-12-19 17:28:15
Subsystem: snit Assigned To: wduquette
Priority: 5 Medium Severity: Minor
Status: Open Last Modified: 2014-12-19 18:15:55
Resolution: None Closed By: nobody
    Closed on:
Description:
Error that occurs in destructor overrides error from constructor, so I am unable to get stack trace or error message from original error.

Example:

package require Tcl 8.5
package require snit

snit::type Test {

    constructor {} {
        error "ctor error"
    }

    destructor {
        error "dtor error"
    }

}

catch {Test create %AUTO%} err opts
puts err=$err
puts opts=$opts

Execution result:

$ tclsh8.5 snit-bug.tcl
err=dtor error
opts=-code 1 -level 0 -errorcode NONE -errorinfo {dtor error
    while executing
"error "dtor error""
    (procedure "::Test::Snit_destructor" line 4)
    invoked from within
"${type}::Snit_destructor $type $selfns $win $instance"
    (procedure "::snit::RT.DestroyObject" line 16)
    invoked from within
"::snit::RT.DestroyObject $type $selfns $name"
    (procedure "::snit::RT.type.typemethod.create" line 55)
    invoked from within
"Test create %AUTO%"} -errorline 1

There are no any information about "ctor error".

I suggest to add constructor error and stack trace to destructor error to provide more useful information for error analysis.