Skip to content

Commit b05ece9

Browse files
committed
docs
1 parent f710c7a commit b05ece9

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

plugin/method-channel.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -233,19 +233,24 @@ func (m *MethodChannel) handleMethodCall(handler MethodHandler, methodName strin
233233
responseSender.Send(binaryReply)
234234
}
235235

236+
// This error can be thrown from a go-flutter plugin. Useful if
237+
// you are interested in returning custom error codes.
238+
// If that is not the case, you can just throw normal Go 'error's
236239
type PluginError struct {
237-
err string
238-
code string
240+
err string
241+
code string
239242
}
240243

244+
// Needed to comply with the Golang 'error' interface
241245
func (e *PluginError) Error() string {
242-
return e.err
246+
return e.err
243247
}
244248

245-
func NewPluginError(code string, err error) (*PluginError) {
249+
// Create an error with an specific error code
250+
func NewPluginError(code string, err error) *PluginError {
246251
pe := &PluginError{
247-
code: code,
248-
err: err.Error(),
252+
code: code,
253+
err: err.Error(),
249254
}
250255
return pe
251-
}
256+
}

0 commit comments

Comments
 (0)