Skip to content

Commit 05830cb

Browse files
committed
makes the MethodChannel Error get vet complient
1 parent b05ece9 commit 05830cb

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

plugin/method-channel.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ func (m *MethodChannel) handleMethodCall(handler MethodHandler, methodName strin
213213

214214
var errorCode string
215215
switch t := err.(type) {
216-
case *PluginError:
216+
case *Error:
217217
errorCode = t.code
218218
default:
219219
errorCode = "error"
@@ -233,22 +233,22 @@ 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
239-
type PluginError struct {
236+
// Error implement the Go error interface, can be thrown from a go-flutter
237+
// method channel plugin to return custom error codes.
238+
// Normal Go error can also be used, the error code will default to "error".
239+
type Error struct {
240240
err string
241241
code string
242242
}
243243

244-
// Needed to comply with the Golang 'error' interface
245-
func (e *PluginError) Error() string {
244+
// Error is needed to comply with the Golang error interface.
245+
func (e *Error) Error() string {
246246
return e.err
247247
}
248248

249-
// Create an error with an specific error code
250-
func NewPluginError(code string, err error) *PluginError {
251-
pe := &PluginError{
249+
// NewError create an error with an specific error code.
250+
func NewError(code string, err error) *Error {
251+
pe := &Error{
252252
code: code,
253253
err: err.Error(),
254254
}

0 commit comments

Comments
 (0)