Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
return distinct error type on input error
- Loading branch information
Showing
4 changed files
with
54 additions
and
22 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,40 @@ | ||
package torrent | ||
|
||
import ( | ||
"github.com/cenkalti/rain/internal/announcer" | ||
) | ||
|
||
// InputError is returned from Session.AddTorrent and Session.AddURI methods when there is problem with the input. | ||
type InputError struct { | ||
err error | ||
} | ||
|
||
func newInputError(err error) *InputError { | ||
return &InputError{ | ||
err: err, | ||
} | ||
} | ||
|
||
func (e *InputError) Error() string { | ||
return "input error: " + e.err.Error() | ||
} | ||
|
||
func (e *InputError) Unwrap() error { | ||
return e.err | ||
} | ||
|
||
type AnnounceError struct { | ||
err *announcer.AnnounceError | ||
} | ||
|
||
func (e *AnnounceError) Error() string { | ||
return e.err.Message | ||
} | ||
|
||
func (e *AnnounceError) Unwrap() error { | ||
return e.err.Err | ||
} | ||
|
||
func (e *AnnounceError) Unknown() bool { | ||
return e.err.Unknown | ||
} |
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
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
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