Bring in more old behaviour, use types for peer_id and infohash

This commit is contained in:
Justin Li
2016-02-15 19:49:25 -05:00
committed by Jimmy Zelinskie
parent 05b7b955a1
commit 75b4a20e56
21 changed files with 529 additions and 259 deletions

41
errors/errors.go Normal file
View File

@@ -0,0 +1,41 @@
// Copyright 2016 The Chihaya Authors. All rights reserved.
// Use of this source code is governed by the BSD 2-Clause license,
// which can be found in the LICENSE file.
package errors
import "net/http"
type Error struct {
message string
public bool
status int
}
func (e *Error) Error() string {
return e.message
}
func (e *Error) Public() bool {
return e.public
}
func (e *Error) Status() int {
return e.status
}
func NewBadRequest(msg string) error {
return &Error{
message: msg,
public: true,
status: http.StatusBadRequest,
}
}
func NewMessage(msg string) error {
return &Error{
message: msg,
public: true,
status: http.StatusOK,
}
}