mirror of
https://github.com/sot-tech/mochi.git
synced 2026-05-02 18:39:59 -07:00
Bring in more old behaviour, use types for peer_id and infohash
This commit is contained in:
committed by
Jimmy Zelinskie
parent
05b7b955a1
commit
75b4a20e56
41
errors/errors.go
Normal file
41
errors/errors.go
Normal 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,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user