Skip to content
This repository was archived by the owner on Jul 1, 2024. It is now read-only.

Commit dbfd321

Browse files
author
Zeph / Liz Loss-Cutler-Hull
committed
Handle RST error names.
Because obex is just different enough to cause much pain.
1 parent 85dc80e commit dbfd321

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

gen/generator/generator_tpl.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,13 @@ func ErrorsTemplate(filename string, apis []*types.ApiGroup) error {
6464
}
6565

6666
for i, err := range errors {
67+
base := err[strings.LastIndex(err, ".")+1:]
68+
if strings.Contains(err, "obex") {
69+
base = "Obex" + base
70+
}
6771
errorsList.List[i] = types.BluezError{
68-
Name: strings.Replace(err, "org.bluez.Error.", "", 1),
72+
Name: err,
73+
Base: base,
6974
}
7075
}
7176

gen/generator/tpl/errors.go.tpl

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import (
88

99
var (
1010
{{- range .List }}
11-
// {{.Name}} map to org.bluez.Error.{{.Name}}
12-
Err{{.Name}} = dbus.Error{
13-
Name: "org.bluez.Error.{{.Name}}",
14-
Body: []interface{}{"{{.Name}}"},
11+
// {{.Base}} map to {{.Name}}
12+
Err{{.Base}} = dbus.Error{
13+
Name: "{{.Name}}",
14+
Body: []interface{}{"{{.Base}}"},
1515
}
1616
{{- end }}
1717
)

gen/types/generator.go

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package types
22

33
type BluezError struct {
44
Name string
5+
Base string
56
Error string
67
}
78

0 commit comments

Comments
 (0)