-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
flathttp/error, flathttp/server: cleanup error handling, and separate…
… errors and error utils into a separate file
- Loading branch information
Showing
2 changed files
with
49 additions
and
53 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,25 @@ | ||
package flathttp | ||
|
||
import ( | ||
"errors" | ||
"io" | ||
"net" | ||
"net/http" | ||
) | ||
|
||
var ErrAlreadyListening = errors.New("already listening") | ||
|
||
func eof(err error) error { | ||
var op *net.OpError | ||
|
||
switch { | ||
case errors.As(err, &op) && op.Err.Error() == "use of closed network connection": | ||
return nil | ||
case errors.Is(err, http.ErrServerClosed): | ||
return nil | ||
case errors.Is(err, io.EOF): | ||
return nil | ||
default: | ||
return err | ||
} | ||
} |
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