-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Go package: elist.
Dr. Alan U. Kennington.
The elist package implements the error-message-stack class Elist, which implements the standard Go interface error.
An Elist permits multiple errors messages to be pushed onto a single error-message-stack. Usage example:
func function0() error { var E error = function1(); if E != nil { return elist.Push(E, "function0: error returned by function1"); } return nil; }
Any kind of error interface-implementation can be chained into an Elist.
The output from Elist::Error() has the error-traceback form suggested by this example.
Error 1: "function0: error returned by function1". Error 2: "function1: error returned by function2". Error 3: "function2: [error description etc.]".
When the calling function function0() does not receive an error message from a called function function1(), a new Elist error-message-stack may be created as in the following example.
func function0() error { var n int = function1(); if n < 0 { return elist.Newf( "function0: negative value returned by function1: %d", n); } return nil; }
Then the caller of function0() may either print the error message which is returned, or else push a new message onto the returned message and pass that as a return value.