mirror of
https://github.com/navidrome/navidrome.git
synced 2026-05-03 06:51:16 +00:00
refactor(generator): remove error handling for response.Error in client templates
Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
parent
ba27a8ceef
commit
c059db4c9c
@ -175,10 +175,10 @@ func serviceClientNeedsJSON(svc Service) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// serviceClientNeedsErrors returns true if any method needs the errors package in client code.
|
// serviceClientNeedsErrors returns true if any method needs the errors package in client code.
|
||||||
// This is true if any method returns an error.
|
// This is only true for error-only methods (methods that return just error).
|
||||||
func serviceClientNeedsErrors(svc Service) bool {
|
func serviceClientNeedsErrors(svc Service) bool {
|
||||||
for _, m := range svc.Methods {
|
for _, m := range svc.Methods {
|
||||||
if m.HasError {
|
if m.IsErrorOnly() {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -79,10 +79,6 @@ func {{$.Service.Name}}{{.Name}}({{range $i, $p := .Params}}{{if $i}}, {{end}}{{
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if response.Error != "" {
|
|
||||||
return nil, errors.New(response.Error)
|
|
||||||
}
|
|
||||||
|
|
||||||
return &response, nil
|
return &response, nil
|
||||||
{{- else if isErrorOnly .}}
|
{{- else if isErrorOnly .}}
|
||||||
{{- /* Error-only response - string result */}}
|
{{- /* Error-only response - string result */}}
|
||||||
|
|||||||
@ -7,7 +7,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
|
||||||
|
|
||||||
"github.com/extism/go-pdk"
|
"github.com/extism/go-pdk"
|
||||||
)
|
)
|
||||||
@ -41,9 +40,5 @@ func CodecEncode(data []byte) (*CodecEncodeResponse, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if response.Error != "" {
|
|
||||||
return nil, errors.New(response.Error)
|
|
||||||
}
|
|
||||||
|
|
||||||
return &response, nil
|
return &response, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,7 +7,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
|
||||||
|
|
||||||
"github.com/extism/go-pdk"
|
"github.com/extism/go-pdk"
|
||||||
)
|
)
|
||||||
@ -41,9 +40,5 @@ func EchoEcho(message string) (*EchoEchoResponse, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if response.Error != "" {
|
|
||||||
return nil, errors.New(response.Error)
|
|
||||||
}
|
|
||||||
|
|
||||||
return &response, nil
|
return &response, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,7 +7,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
|
||||||
|
|
||||||
"github.com/extism/go-pdk"
|
"github.com/extism/go-pdk"
|
||||||
)
|
)
|
||||||
@ -47,9 +46,5 @@ func ListItems(name string, filter Filter) (*ListItemsResponse, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if response.Error != "" {
|
|
||||||
return nil, errors.New(response.Error)
|
|
||||||
}
|
|
||||||
|
|
||||||
return &response, nil
|
return &response, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,7 +7,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
|
||||||
|
|
||||||
"github.com/extism/go-pdk"
|
"github.com/extism/go-pdk"
|
||||||
)
|
)
|
||||||
@ -39,9 +38,5 @@ func MathAdd(a int32, b int32) (*MathAddResponse, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if response.Error != "" {
|
|
||||||
return nil, errors.New(response.Error)
|
|
||||||
}
|
|
||||||
|
|
||||||
return &response, nil
|
return &response, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,10 +46,6 @@ func MetaGet(key string) (*MetaGetResponse, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if response.Error != "" {
|
|
||||||
return nil, errors.New(response.Error)
|
|
||||||
}
|
|
||||||
|
|
||||||
return &response, nil
|
return &response, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -7,7 +7,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
|
||||||
|
|
||||||
"github.com/extism/go-pdk"
|
"github.com/extism/go-pdk"
|
||||||
)
|
)
|
||||||
@ -42,9 +41,5 @@ func SearchFind(query string) (*SearchFindResponse, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if response.Error != "" {
|
|
||||||
return nil, errors.New(response.Error)
|
|
||||||
}
|
|
||||||
|
|
||||||
return &response, nil
|
return &response, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,7 +7,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
|
||||||
|
|
||||||
"github.com/extism/go-pdk"
|
"github.com/extism/go-pdk"
|
||||||
)
|
)
|
||||||
@ -45,9 +44,5 @@ func StoreSave(item Item) (*StoreSaveResponse, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if response.Error != "" {
|
|
||||||
return nil, errors.New(response.Error)
|
|
||||||
}
|
|
||||||
|
|
||||||
return &response, nil
|
return &response, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,7 +7,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
|
||||||
|
|
||||||
"github.com/extism/go-pdk"
|
"github.com/extism/go-pdk"
|
||||||
)
|
)
|
||||||
@ -51,9 +50,5 @@ func UsersGet(id *string, filter *User) (*UsersGetResponse, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if response.Error != "" {
|
|
||||||
return nil, errors.New(response.Error)
|
|
||||||
}
|
|
||||||
|
|
||||||
return &response, nil
|
return &response, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,7 +7,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
|
||||||
|
|
||||||
"github.com/extism/go-pdk"
|
"github.com/extism/go-pdk"
|
||||||
)
|
)
|
||||||
@ -45,9 +44,5 @@ func SubsonicAPICall(uri string) (*SubsonicAPICallResponse, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if response.Error != "" {
|
|
||||||
return nil, errors.New(response.Error)
|
|
||||||
}
|
|
||||||
|
|
||||||
return &response, nil
|
return &response, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -66,6 +66,12 @@ func callSubsonicAPIExport() int32 {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check for error in response
|
||||||
|
if response.Error != "" {
|
||||||
|
pdk.SetErrorString("SubsonicAPI error: " + response.Error)
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
// Return the response
|
// Return the response
|
||||||
pdk.OutputString(response.ResponseJSON)
|
pdk.OutputString(response.ResponseJSON)
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
@ -7,7 +7,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
|
||||||
|
|
||||||
"github.com/extism/go-pdk"
|
"github.com/extism/go-pdk"
|
||||||
)
|
)
|
||||||
@ -45,9 +44,5 @@ func SubsonicAPICall(uri string) (*SubsonicAPICallResponse, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if response.Error != "" {
|
|
||||||
return nil, errors.New(response.Error)
|
|
||||||
}
|
|
||||||
|
|
||||||
return &response, nil
|
return &response, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user