-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.go
More file actions
45 lines (34 loc) · 922 Bytes
/
Copy patherrors.go
File metadata and controls
45 lines (34 loc) · 922 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright 2015 Giulio Iotti. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package plugin_go
import (
"errors"
"strings"
)
const (
errorCodeConnFailed = "err-connection-failed"
errorCodeHttpServe = "err-http-serve"
)
// 连接到外部插件失败的出错信息
type ErrConnectionFailed error
// 外部插件无法开始侦听调用时的出错信息
type ErrHttpServe error
// 外部插件打印无效消息时的出错信息
type ErrInvalidMessage error
// 插件注册失败时的出错信息
type ErrRegistrationTimeout error
func parseError(line string) error {
parts := strings.SplitN(line, ": ", 2)
if parts[0] == "" {
return nil
}
err := errors.New(parts[1])
switch parts[0] {
case errorCodeConnFailed:
return ErrConnectionFailed(err)
case errorCodeHttpServe:
return ErrHttpServe(err)
}
return err
}