Skip to content
This repository has been archived by the owner on Oct 17, 2023. It is now read-only.

Commit

Permalink
Merge pull request #31 from compose/clearer_errors
Browse files Browse the repository at this point in the history
add some more information in errors that we get in the javascript.
  • Loading branch information
nstott committed Dec 29, 2014
2 parents dd9ed6f + 8b6b076 commit 0077eaf
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions cmd/transporter/javascript_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (js *JavascriptBuilder) source(call otto.FunctionCall) otto.Value {

node, err := js.findNode(call.Argument(0))
if err != nil {
js.err = err
js.err = fmt.Errorf("source error, %s", err.Error())
return otto.NullValue()
}
js.nodes[node.UUID] = node // persist this
Expand All @@ -90,7 +90,7 @@ func (js *JavascriptBuilder) source(call otto.FunctionCall) otto.Value {
func (js *JavascriptBuilder) save(node Node, call otto.FunctionCall) (Node, error) {
thisNode, err := js.findNode(call.Argument(0))
if err != nil {
return node, err
return node, fmt.Errorf("save error, %s", err.Error())
}
root := js.nodes[node.RootUUID]

Expand All @@ -102,7 +102,7 @@ func (js *JavascriptBuilder) save(node Node, call otto.FunctionCall) (Node, erro
}

js.nodes[root.UUID] = root
return root, err
return root, nil
}

// adds a transform function to the transporter pipeline
Expand All @@ -115,7 +115,7 @@ func (js *JavascriptBuilder) transform(node Node, call otto.FunctionCall) (Node,

rawMap, ok := e.(map[string]interface{})
if !ok {
return node, fmt.Errorf("first argument must be an hash. (got %T instead)", e)
return node, fmt.Errorf("transform error. first argument must be an hash. (got %T instead)", e)
}

filename, ok := rawMap["filename"].(string)
Expand All @@ -132,14 +132,14 @@ func (js *JavascriptBuilder) transform(node Node, call otto.FunctionCall) (Node,
if !(ok) {
u, err := uuid.NewV4()
if err != nil {
return node, err
return node, fmt.Errorf("transform error. uuid error (%s)", err.Error())
}
name = u.String()
}

transformer, err := NewNode(name, "transformer", adaptor.Config{"filename": filename, "debug": debug})
if err != nil {
return node, err
return node, fmt.Errorf("transform error. cannot create node (%s)", err.Error())
}

node.Add(&transformer)
Expand Down

0 comments on commit 0077eaf

Please sign in to comment.