Blob


1 package nntp
3 import "fmt"
5 // An NNTPError is a coded NNTP error message.
6 type Error struct {
7 Code int
8 Msg string
9 }
11 func (e *Error) Error() string {
12 return fmt.Sprintf("%d %s", e.Code, e.Msg)
13 }
15 // ErrNoSuchGroup is returned for a request for a group that can't be found.
16 var ErrNoSuchGroup = &Error{411, "No such newsgroup"}
18 // ErrNoSuchGroup is returned for a request that requires a current
19 // group when none has been selected.
20 var ErrNoGroupSelected = &Error{412, "No newsgroup selected"}
22 // ErrInvalidMessageID is returned when a message is requested that can't be found.
23 var ErrInvalidMessageID = &Error{430, "No article with that message-id"}
25 // ErrInvalidArticleNumber is returned when an article is requested that can't be found.
26 var ErrInvalidArticleNumber = &Error{423, "No article with that number"}
28 // ErrNoCurrentArticle is returned when a command is executed that
29 // requires a current article when one has not been selected.
30 var ErrNoCurrentArticle = &Error{420, "Current article number is invalid"}
32 // ErrUnknownCommand is returned for unknown comands.
33 var ErrUnknownCommand = &Error{500, "Unknown command"}
35 // ErrSyntax is returned when a command can't be parsed.
36 var ErrSyntax = &Error{501, "not supported, or syntax error"}
38 // ErrPostingNotPermitted is returned as the response to an attempt to
39 // post an article where posting is not permitted.
40 var ErrPostingNotPermitted = &Error{440, "posting not permitted"}
42 // ErrPostingFailed is returned when an attempt to post an article fails.
43 var ErrPostingFailed = &Error{441, "posting failed"}
45 // ErrNotWanted is returned when an attempt to post an article is
46 // rejected due the server not wanting the article.
47 var ErrNotWanted = &Error{435, "Article not wanted"}
49 // ErrAuthRequired is returned to indicate authentication is required
50 // to proceed.
51 var ErrAuthRequired = &Error{450, "authorization required"}
53 // ErrAuthRejected is returned for invalid authentication.
54 var ErrAuthRejected = &Error{452, "authorization rejected"}
56 // ErrNotAuthenticated is returned when a command is issued that requires
57 // authentication, but authentication was not provided.
58 var ErrNotAuthenticated = &Error{480, "authentication required"}