Skip to content

Commit 9b76806

Browse files
committed
improve error message
1 parent bcd8649 commit 9b76806

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

node.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ func (n *Node) WriteFrameExcept(exceptChannel *Channel, fr frame.Frame) error {
602602
// SendCommandLong sends a COMMAND_LONG and waits for COMMAND_ACK response.
603603
func (n *Node) SendCommandLong(command *common.MessageCommandLong, options *CommandOptions) (*CommandResponse, error) {
604604
if n.nodeCommand == nil {
605-
return nil, fmt.Errorf("command manager not initialized (dialect required)")
605+
return nil, fmt.Errorf("command manager not available (COMMAND_LONG, COMMAND_INT or COMMAND_ACK missing from dialect)")
606606
}
607607

608608
if n.nodeCommand.msgCommandLong == nil {
@@ -621,7 +621,7 @@ func (n *Node) SendCommandLong(command *common.MessageCommandLong, options *Comm
621621
// SendCommandInt sends a COMMAND_INT and waits for COMMAND_ACK response.
622622
func (n *Node) SendCommandInt(command *common.MessageCommandInt, options *CommandOptions) (*CommandResponse, error) {
623623
if n.nodeCommand == nil {
624-
return nil, fmt.Errorf("command manager not initialized (dialect required)")
624+
return nil, fmt.Errorf("command manager not available (COMMAND_LONG, COMMAND_INT or COMMAND_ACK missing from dialect)")
625625
}
626626

627627
if n.nodeCommand.msgCommandInt == nil {

node_command_test.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -515,8 +515,7 @@ func TestNodeCommandWithoutDialect(t *testing.T) {
515515
Timeout: 1 * time.Second,
516516
})
517517

518-
require.Error(t, err)
519-
require.Contains(t, err.Error(), "command manager not initialized")
518+
require.EqualError(t, err, "command manager not available (COMMAND_LONG, COMMAND_INT or COMMAND_ACK missing from dialect)")
520519
}
521520

522521
// TestNodeCommandMultipleSimultaneous tests multiple commands in flight
@@ -1021,8 +1020,7 @@ func TestNodeCommandIntNotAvailable(t *testing.T) {
10211020
Timeout: 1 * time.Second,
10221021
})
10231022

1024-
require.Error(t, err)
1025-
require.Contains(t, err.Error(), "command manager not initialized")
1023+
require.EqualError(t, err, "command manager not available (COMMAND_LONG, COMMAND_INT or COMMAND_ACK missing from dialect)")
10261024
}
10271025

10281026
// TestNodeCommandLongNotAvailable tests SendCommandLong when COMMAND_LONG not in dialect
@@ -1064,8 +1062,7 @@ func TestNodeCommandLongNotAvailable(t *testing.T) {
10641062
Timeout: 1 * time.Second,
10651063
})
10661064

1067-
require.Error(t, err)
1068-
require.Contains(t, err.Error(), "command manager not initialized")
1065+
require.EqualError(t, err, "command manager not available (COMMAND_LONG, COMMAND_INT or COMMAND_ACK missing from dialect)")
10691066
}
10701067

10711068
// TestNodeCommandAckWithExtensionFields tests that extension fields are properly handled

node_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,5 @@ func TestNodeCommandManagerNotInitialized(t *testing.T) {
781781
Timeout: 1 * time.Second,
782782
})
783783

784-
require.Error(t, err)
785-
require.Contains(t, err.Error(), "command manager not initialized")
784+
require.EqualError(t, err, "command manager not available (COMMAND_LONG, COMMAND_INT or COMMAND_ACK missing from dialect)")
786785
}

0 commit comments

Comments
 (0)