diff options
| author | citrons <citrons@mondecitronne.com> | 2025-06-01 15:26:52 -0500 |
|---|---|---|
| committer | citrons <citrons@mondecitronne.com> | 2025-06-01 15:27:06 -0500 |
| commit | f22f12b4fc1c9aa733cf68000afb425a87dcc222 (patch) | |
| tree | a5255e4e426bc029feb08ae79e2fbfc5bde661db | |
| parent | 6858497999286700603b8cf54741d13269e7736c (diff) | |
error message strings
| -rw-r--r-- | proto/fail.go | 2 | ||||
| -rw-r--r-- | proto/strfail.go | 22 |
2 files changed, 23 insertions, 1 deletions
diff --git a/proto/fail.go b/proto/fail.go index 0b6366b..bd54965 100644 --- a/proto/fail.go +++ b/proto/fail.go @@ -7,5 +7,5 @@ func (f Fail) Cmd() Command { } func (f Fail) Error() string { - return f.Kind + return Strfail(Object(f)) } diff --git a/proto/strfail.go b/proto/strfail.go new file mode 100644 index 0000000..83f314b --- /dev/null +++ b/proto/strfail.go @@ -0,0 +1,22 @@ +package proto + +func Strfail(fail Object) string { + switch fail.Kind { + case "bad-target": + return "unknown user or channel" + case "unknown-name": + return "unknown user or channel name" + case "invalid": + return "invalid action" + case "forbidden": + return "you don't have permission to do that" + case "name-taken": + return "name is in use: " + fail.Fields[""] + case "invalid-name": + return "name is too long or contains invalid characters: " + fail.Fields[""] + case "not-in-channel": + return "you are not a member of this channel: " + fail.Fields[""] + default: + return "unknown error" + } +} |
