[Grace-core] Failure handling

Andrew P. Black black at cs.pdx.edu
Thu Jun 28 17:08:57 PDT 2012


Michael has added failure and failure handling to the compiler!

This summarizes what's there:

var x := 0
try {
    x.fail
} else {
    print "Handled error"
}

The try branch will fail (a no such method error), but the else branch will be executed instead, and the whole construct succeeds.

There is now a clean way to force an error:

	forceError "message"

So this works:

try {
    forceError "die"
} else {
    print "OK"
}

Smita, I started editing this into the GUnit.grace code, but ran out of time.  Errors work, but the test of  failures does not, because the result object isn't available in the write place to do the result.assert.  Some restructuring is necessary.  I think that the result should be a collecting parameter passed to run.
This is probably all in the book, or you can figure it out for yourself ;-)

	Andrew



More information about the Grace-core mailing list