mirror of
https://github.com/golang/go
synced 2024-11-19 02:14:43 -07:00
export an os.Error constructor
R=r DELTA=20 (6 added, 7 deleted, 7 changed) OCL=15569 CL=15571
This commit is contained in:
parent
66b261a082
commit
0e81bba1fe
@ -12,19 +12,13 @@ import (
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func NewError(s string) *os.Error {
|
||||
e := new(os.Error);
|
||||
e.s = s;
|
||||
return e
|
||||
}
|
||||
|
||||
export var (
|
||||
BadAddress = NewError("malformed address");
|
||||
MissingAddress = NewError("missing address");
|
||||
UnknownNetwork = NewError("unknown network");
|
||||
UnknownHost = NewError("unknown host");
|
||||
UnknownPort = NewError("unknown port");
|
||||
UnknownSocketFamily = NewError("unknown socket family");
|
||||
BadAddress = os.NewError("malformed address");
|
||||
MissingAddress = os.NewError("missing address");
|
||||
UnknownNetwork = os.NewError("unknown network");
|
||||
UnknownHost = os.NewError("unknown host");
|
||||
UnknownPort = os.NewError("unknown port");
|
||||
UnknownSocketFamily = os.NewError("unknown socket family");
|
||||
)
|
||||
|
||||
// Split "host:port" into "host" and "port".
|
||||
|
@ -14,6 +14,12 @@ export type Error struct {
|
||||
|
||||
var ErrorTab = new(map[int64] *Error);
|
||||
|
||||
export func NewError(s string) *Error {
|
||||
e := new(Error);
|
||||
e.s = s
|
||||
return e
|
||||
}
|
||||
|
||||
export func ErrnoToError(errno int64) *Error {
|
||||
if errno == 0 {
|
||||
return nil
|
||||
@ -22,8 +28,7 @@ export func ErrnoToError(errno int64) *Error {
|
||||
if ok {
|
||||
return err
|
||||
}
|
||||
e := new(Error);
|
||||
e.s = syscall.errstr(errno);
|
||||
e := NewError(syscall.errstr(errno));
|
||||
ErrorTab[errno] = e;
|
||||
return e;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user