export an os.Error constructor

R=r
DELTA=20  (6 added, 7 deleted, 7 changed)
OCL=15569
CL=15571
This commit is contained in:
Russ Cox 2008-09-19 15:23:16 -07:00
parent 66b261a082
commit 0e81bba1fe
2 changed files with 13 additions and 14 deletions

View file

@ -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;
}