Commit 3b36acc7 authored by Russ Cox's avatar Russ Cox

move ShortWrite error into io so that other packages can use it.

R=r
DELTA=15  (7 added, 1 deleted, 7 changed)
OCL=28996
CL=28996
parent 23c81f74
...@@ -30,11 +30,10 @@ type Error struct { ...@@ -30,11 +30,10 @@ type Error struct {
} }
var ( var (
PhaseError os.Error = &Error{"phase error"}; PhaseError os.Error = &Error{"bufio: phase error"};
BufferFull os.Error = &Error{"buffer full"}; BufferFull os.Error = &Error{"bufio: buffer full"};
InternalError os.Error = &Error{"bufio internal error"}; InternalError os.Error = &Error{"bufio: internal error"};
BadBufSize os.Error = &Error{"bad bufio size"}; BadBufSize os.Error = &Error{"bufio: bad buffer size"};
ShortWrite os.Error = &Error{"short write"};
) )
func copySlice(dst []byte, src []byte) { func copySlice(dst []byte, src []byte) {
...@@ -427,7 +426,7 @@ func (b *Writer) Flush() os.Error { ...@@ -427,7 +426,7 @@ func (b *Writer) Flush() os.Error {
m, e := b.wr.Write(b.buf[n:b.n]); m, e := b.wr.Write(b.buf[n:b.n]);
n += m; n += m;
if m == 0 && e == nil { if m == 0 && e == nil {
e = ShortWrite e = io.ErrShortWrite
} }
if e != nil { if e != nil {
if n < b.n { if n < b.n {
......
...@@ -177,7 +177,7 @@ func (c *Conn) Write(data []byte) (n int, err os.Error) { ...@@ -177,7 +177,7 @@ func (c *Conn) Write(data []byte) (n int, err os.Error) {
n, err = c.buf.Write(data); n, err = c.buf.Write(data);
if err == nil && c.chunking { if err == nil && c.chunking {
if n != len(data) { if n != len(data) {
err = bufio.ShortWrite; err = io.ErrShortWrite;
} }
if err == nil { if err == nil {
io.WriteString(c.buf, "\r\n"); io.WriteString(c.buf, "\r\n");
......
...@@ -13,12 +13,19 @@ import ( ...@@ -13,12 +13,19 @@ import (
"os"; "os";
) )
// ErrEOF is the error returned by FullRead and Copyn when they encounter EOF. // Error represents an unexpected I/O behavior.
type Error struct { type Error struct {
os.ErrorString os.ErrorString
} }
// ErrEOF means that data was expected, but a read got EOF instead.
var ErrEOF os.Error = &Error{"EOF"} var ErrEOF os.Error = &Error{"EOF"}
// ErrShortWrite means that a write accepted fewer bytes than requested
// but failed to return an explicit error.
var ErrShortWrite os.Error = &Error{"short write"}
// Reader is the interface that wraps the basic Read method. // Reader is the interface that wraps the basic Read method.
type Reader interface { type Reader interface {
Read(p []byte) (n int, err os.Error); Read(p []byte) (n int, err os.Error);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment