@@ -72,90 +72,90 @@ func Try(f interface{}) (o *Outcome) {
7272
7373// Catch calls the provided function passing the receiver Outcome as argument,
7474// only if the Outcome is at PANIC level.
75- func (this * Outcome ) Catch (f func (* Outcome )) * Outcome {
76- if this .level == PANIC {
77- f (this )
75+ func (o * Outcome ) Catch (f func (* Outcome )) * Outcome {
76+ if o .level == PANIC {
77+ f (o )
7878 }
79- return this
79+ return o
8080}
8181
8282// KeepCalm downgrades a PANIC to ERROR level, to avoid triggering a panic upon
8383// logging the outcome.
84- func (this * Outcome ) KeepCalm () * Outcome {
85- if this .level == PANIC {
86- this .level = ERROR
84+ func (o * Outcome ) KeepCalm () * Outcome {
85+ if o .level == PANIC {
86+ o .level = ERROR
8787 }
88- return this
88+ return o
8989}
9090
9191// Escalate converts a PANIC into a FATAL condition, to trigger program
9292// termination upon logging the outcome.
93- func (this * Outcome ) Escalate () * Outcome {
94- if this .level == PANIC {
95- this .level = FATAL
93+ func (o * Outcome ) Escalate () * Outcome {
94+ if o .level == PANIC {
95+ o .level = FATAL
9696 }
97- return this
97+ return o
9898}
9999
100100// Log sends the error-condition Outcome to the provided log, using the appropriate
101101// logging function: FATAL conditions are logged using Fatal(), PANIC using
102102// Panic(), and ERROR using Print(). Non-error conditions are not logged
103103// because there is no information stored in the Outcome, beside
104104// what the Try-ed function returned (and is better suited to log itself).
105- func (this * Outcome ) Log (log Logger ) * Outcome {
106- switch this .level {
105+ func (o * Outcome ) Log (log Logger ) * Outcome {
106+ switch o .level {
107107 case FATAL :
108- log .Fatal (this )
108+ log .Fatal (o )
109109 case PANIC :
110- log .Panic (this )
110+ log .Panic (o )
111111 case ERROR :
112- log .Print (this )
112+ log .Print (o )
113113 }
114- return this
114+ return o
115115}
116116
117117// Level returns the error level stored by the receiver.
118- func (this * Outcome ) Level () int8 {
119- return this .level
118+ func (o * Outcome ) Level () int8 {
119+ return o .level
120120}
121121
122122// SetLevel sets the error level stored by the receiver.
123- func (this * Outcome ) SetLevel (l int8 ) * Outcome {
123+ func (o * Outcome ) SetLevel (l int8 ) * Outcome {
124124 if levelName (l ) != "?" {
125- this .level = l
125+ o .level = l
126126 }
127- return this
127+ return o
128128}
129129
130130// Code returns the error code stored by the receiver.
131- func (this * Outcome ) Code () int {
132- return this .code
131+ func (o * Outcome ) Code () int {
132+ return o .code
133133}
134134
135135// SetCode sets the error code stored by the receiver.
136- func (this * Outcome ) SetCode (c int ) * Outcome {
137- this .code = c
138- return this
136+ func (o * Outcome ) SetCode (c int ) * Outcome {
137+ o .code = c
138+ return o
139139}
140140
141141// Text returns the error text stored by the receiver.
142- func (this * Outcome ) Text () string {
143- return this .text
142+ func (o * Outcome ) Text () string {
143+ return o .text
144144}
145145
146146// SetText sets the error text stored by the receiver.
147- func (this * Outcome ) SetText (t string ) * Outcome {
148- this .text = t
149- return this
147+ func (o * Outcome ) SetText (t string ) * Outcome {
148+ o .text = t
149+ return o
150150}
151151
152152// Info returns the error info stored by the receiver.
153- func (this * Outcome ) Info () []string {
154- return this .info
153+ func (o * Outcome ) Info () []string {
154+ return o .info
155155}
156156
157157// addInfo adds (more) error info to the receiver.
158- func (this * Outcome ) addInfo (calldepth int , s ... string ) * Outcome {
158+ func (o * Outcome ) addInfo (calldepth int , s ... string ) * Outcome {
159159 for i , line := range s {
160160 if line == "debug.stack" {
161161 calldepth *= 2
@@ -181,41 +181,41 @@ func (this *Outcome) addInfo(calldepth int, s ...string) *Outcome {
181181 break
182182 }
183183 }
184- this .info = append (this .info , s ... )
185- return this
184+ o .info = append (o .info , s ... )
185+ return o
186186}
187187
188188// AddInfo adds (more) error info to the receiver.
189- func (this * Outcome ) AddInfo (s ... string ) * Outcome {
190- return this .addInfo (2 , s ... )
189+ func (o * Outcome ) AddInfo (s ... string ) * Outcome {
190+ return o .addInfo (2 , s ... )
191191}
192192
193193// Value provides the value returned by the Try-ed function, if any.
194- func (this * Outcome ) Value () interface {} {
195- return this .val
194+ func (o * Outcome ) Value () interface {} {
195+ return o .val
196196}
197197
198198// Err provides the error returned by the Try-ed function, if any.
199- func (this * Outcome ) Err () error {
200- return this .err
199+ func (o * Outcome ) Err () error {
200+ return o .err
201201}
202202
203203// Result provides the value and error returned by the Try-ed function, if any.
204- func (this * Outcome ) Result () (interface {}, error ) {
205- return this .val , this .err
204+ func (o * Outcome ) Result () (interface {}, error ) {
205+ return o .val , o .err
206206}
207207
208208// Error returns a string representation of the Outcome if it is in an error condition,
209209// or an empty string if no error or panic occurred. Note that the Try-ed function
210210// returning a non-nil error does not constitute an error condition for the Outcome.
211211// That error value can be retrieved via Err or Result.
212212// This is also useful for satisfying the `error` interface.
213- func (this * Outcome ) Error () string {
214- if this .level == OK {
213+ func (o * Outcome ) Error () string {
214+ if o .level == OK {
215215 return ""
216216 }
217- if this .code != 0 {
218- return this .text + fmt .Sprintf (" (code: 0x%04x)" , this .code )
217+ if o .code != 0 {
218+ return o .text + fmt .Sprintf (" (code: 0x%04x)" , o .code )
219219 }
220- return this .text
220+ return o .text
221221}
0 commit comments