Skip to content

Commit c193c4a

Browse files
committed
Fixed crash when using custom_field_filter with phpipam_addresses data object
1 parent d875abf commit c193c4a

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

phpipam/client/client.go

+10-11
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ package client
44

55
import (
66
"fmt"
7+
"log"
78

89
"github.com/pavel-z1/phpipam-sdk-go/phpipam"
910
"github.com/pavel-z1/phpipam-sdk-go/phpipam/request"
@@ -100,11 +101,9 @@ func (c *Client) GetCustomFields(id int, controller string) (out map[string]inte
100101
var schema map[string]phpipam.CustomField
101102
schema, err = c.GetCustomFieldsSchema(controller)
102103
switch {
103-
case err.Error() == "Error from API (200): No custom fields defined":
104-
err = nil
105-
return
106-
case err != nil:
107-
return
104+
case err != nil:
105+
log.Printf("Error getting custom Fields: %s", err)
106+
return
108107
}
109108

110109
out, err = c.getCustomFieldsRequest(id, controller, schema)
@@ -148,12 +147,12 @@ func (c *Client) UpdateCustomFields(id int, in map[string]interface{}, controlle
148147
var schema map[string]phpipam.CustomField
149148
schema, err = c.GetCustomFieldsSchema(controller)
150149
switch {
151-
// Ignore this error if the caller is not setting any fields.
152-
case len(in) == 0 && err.Error() == "Error from API (200): No custom fields defined":
153-
err = nil
154-
return
155-
case err != nil:
156-
return
150+
// Ignore this error if the caller is not setting any fields.
151+
case len(in) == 0 && err.Error() == "Error from API (200): No custom fields defined":
152+
err = nil
153+
return
154+
case err != nil:
155+
return
157156
}
158157
message, err = c.updateCustomFieldsRequest(id, in, controller, schema)
159158
return

0 commit comments

Comments
 (0)