Blame


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