Skip to content
This repository has been archived by the owner on Aug 31, 2022. It is now read-only.
/ gobolt Public archive

Commit

Permalink
Use valueSystem when creating generic errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ali-ince committed Nov 27, 2018
1 parent 3df1604 commit 5c8150e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ func (connection *neo4jConnection) Fields() ([]string, error) {
return fieldsAsStr, nil
}

return nil, newGenericError("field names not available")
return nil, connection.valueSystem.genericErrorFactory("field names not available")
}

func (connection *neo4jConnection) Metadata() (map[string]interface{}, error) {
Expand All @@ -318,7 +318,7 @@ func (connection *neo4jConnection) Metadata() (map[string]interface{}, error) {
return metadataAsGenericMap, nil
}

return nil, newGenericError("metadata is not of expected type")
return nil, connection.valueSystem.genericErrorFactory("metadata is not of expected type")
}

func (connection *neo4jConnection) Data() ([]interface{}, error) {
Expand Down
8 changes: 4 additions & 4 deletions value.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ func (valueSystem *boltValueSystem) valueAsGo(value *C.struct_BoltValue) (interf
return handler.Read(signature, listValue)
}

return nil, newGenericError("unsupported struct type received: %#x", signature)
return nil, valueSystem.genericErrorFactory("unsupported struct type received: %#x", signature)
}

return nil, newGenericError("unsupported data type")
return nil, valueSystem.genericErrorFactory("unsupported data type")
}

func (valueSystem *boltValueSystem) valueAsBoolean(value *C.struct_BoltValue) bool {
Expand Down Expand Up @@ -298,7 +298,7 @@ func (valueSystem *boltValueSystem) bytesAsValue(target *C.struct_BoltValue, val
func (valueSystem *boltValueSystem) listAsValue(target *C.struct_BoltValue, value interface{}) error {
slice := reflect.ValueOf(value)
if slice.Kind() != reflect.Slice {
return newGenericError("listAsValue invoked with a non-slice type: %v", value)
return valueSystem.genericErrorFactory("listAsValue invoked with a non-slice type: %v", value)
}

C.BoltValue_format_as_List(target, C.int32_t(slice.Len()))
Expand All @@ -315,7 +315,7 @@ func (valueSystem *boltValueSystem) listAsValue(target *C.struct_BoltValue, valu
func (valueSystem *boltValueSystem) mapAsValue(target *C.struct_BoltValue, value interface{}) error {
dict := reflect.ValueOf(value)
if dict.Kind() != reflect.Map {
return newGenericError("mapAsValue invoked with a non-map type: %v", value)
return valueSystem.genericErrorFactory("mapAsValue invoked with a non-map type: %v", value)
}

C.BoltValue_format_as_Dictionary(target, C.int32_t(dict.Len()))
Expand Down

0 comments on commit 5c8150e

Please sign in to comment.