-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package command | ||
|
||
type ErrUnknownCommand struct { | ||
Command string | ||
} | ||
|
||
func (e ErrUnknownCommand) Error() string { | ||
return "unknown command: " + e.Command | ||
} | ||
|
||
type ErrConnectionClosed struct{} | ||
|
||
func (e ErrConnectionClosed) Error() string { | ||
return "connection closed" | ||
} | ||
|
||
type ErrTimeout struct{} | ||
|
||
func (e ErrTimeout) Error() string { | ||
return "timeout" | ||
} | ||
|
||
type ErrUnsupportedMessageType struct { | ||
MsgType string | ||
} | ||
|
||
func (e ErrUnsupportedMessageType) Error() string { | ||
return "unsupported message type: " + e.MsgType | ||
} | ||
|
||
type ErrEmptyRequest struct{} | ||
|
||
func (e ErrEmptyRequest) Error() string { | ||
return "empty request" | ||
} | ||
|
||
type ErrInvalidTimeout struct { | ||
Timeout string | ||
} | ||
|
||
func (e ErrInvalidTimeout) Error() string { | ||
return "invalid timeout: " + e.Timeout | ||
} | ||
|
||
type ErrEmptyCommand struct{} | ||
|
||
func (e ErrEmptyCommand) Error() string { | ||
return "empty command" | ||
} | ||
|
||
type ErrEmptyMacro struct { | ||
MacroName string | ||
} | ||
|
||
func (e ErrEmptyMacro) Error() string { | ||
return "empty macro: " + e.MacroName | ||
} | ||
|
||
type ErrDuplicateMacro struct { | ||
MacroName string | ||
} | ||
|
||
func (e ErrDuplicateMacro) Error() string { | ||
return "duplicate macro: " + e.MacroName | ||
} | ||
|
||
type ErrUnsupportedVersion struct { | ||
Version string | ||
} | ||
|
||
func (e ErrUnsupportedVersion) Error() string { | ||
return "unsupported version: " + e.Version | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package command | ||
|
||
import "testing" | ||
|
||
func TestUnknownCommand_Error(t *testing.T) { | ||
command := "test" | ||
err := ErrUnknownCommand{Command: command} | ||
expected := "unknown command: " + command | ||
|
||
if err.Error() != expected { | ||
t.Errorf("Expected error message '%s', but got '%s'", expected, err.Error()) | ||
} | ||
} | ||
|
||
func TestConnectionClosed_Error(t *testing.T) { | ||
err := ErrConnectionClosed{} | ||
want := "connection closed" | ||
|
||
if got := err.Error(); got != want { | ||
t.Errorf("Error() = %v, want %v", got, want) | ||
} | ||
} | ||
|
||
func TestTimeout_Error(t *testing.T) { | ||
err := ErrTimeout{} | ||
want := "timeout" | ||
|
||
if got := err.Error(); got != want { | ||
t.Errorf("Error() = %v, want %v", got, want) | ||
} | ||
} |