]> Cypherpunks repositories - gostls13.git/commitdiff
os, syscall: update for error
authorRuss Cox <rsc@golang.org>
Wed, 2 Nov 2011 02:12:41 +0000 (22:12 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 2 Nov 2011 02:12:41 +0000 (22:12 -0400)
R=adg
CC=golang-dev
https://golang.org/cl/5333052

src/pkg/os/env_windows.go
src/pkg/os/exec_windows.go
src/pkg/syscall/dll_windows.go

index 9fc61974c4d9dfe09d8c96fb9af28491f4499c9d..795da21a44a3e0b79371be99c2932d2c451bf6c1 100644 (file)
@@ -7,13 +7,14 @@
 package os
 
 import (
+       "errors"
        "syscall"
        "utf16"
        "unsafe"
 )
 
 // ENOENV is the error indicating that an environment variable does not exist.
-var ENOENV = NewError("no such environment variable")
+var ENOENV = errors.New("no such environment variable")
 
 // Getenverror retrieves the value of the environment variable named by the key.
 // It returns the value and an error, if any.
index b2b640c8711a66ed74208e8ab4cced22f479571e..866757e312961a7552df9ded3a7fcddf7b207e1c 100644 (file)
@@ -5,6 +5,7 @@
 package os
 
 import (
+       "errors"
        "runtime"
        "syscall"
 )
@@ -17,7 +18,7 @@ func (p *Process) Wait(options int) (w *Waitmsg, err error) {
        case syscall.WAIT_FAILED:
                return nil, NewSyscallError("WaitForSingleObject", e)
        default:
-               return nil, NewError("os: unexpected result from WaitForSingleObject")
+               return nil, errors.New("os: unexpected result from WaitForSingleObject")
        }
        var ec uint32
        e = syscall.GetExitCodeProcess(syscall.Handle(p.handle), &ec)
@@ -31,7 +32,7 @@ func (p *Process) Wait(options int) (w *Waitmsg, err error) {
 // Signal sends a signal to the Process.
 func (p *Process) Signal(sig Signal) error {
        if p.done {
-               return NewError("os: process already finished")
+               return errors.New("os: process already finished")
        }
        switch sig.(UnixSignal) {
        case SIGKILL:
index 1873d0c90d8d858459841feef771733496464e0d..6815dee058f004c7bab6daf7ddf99b6fe97363c3 100644 (file)
@@ -8,15 +8,10 @@ import (
        "sync"
 )
 
-// An Error can represent any printable error condition.
-type Error interface {
-       String() string
-}
-
 // Errno is the Windows error number.
 type Errno uint64
 
-func (e Errno) String() string { return Errstr(int(e)) }
+func (e Errno) Error() string { return Errstr(int(e)) }
 
 // DLLError describes reasons for DLL load failures.
 type DLLError struct {
@@ -42,7 +37,7 @@ type DLL struct {
 }
 
 // LoadDLL loads DLL file into memory.
-func LoadDLL(name string) (dll *DLL, err Error) {
+func LoadDLL(name string) (dll *DLL, err error) {
        h, e := loadlibrary(StringToUTF16Ptr(name))
        if e != 0 {
                return nil, &DLLError{
@@ -69,7 +64,7 @@ func MustLoadDLL(name string) *DLL {
 
 // FindProc searches DLL d for procedure named name and returns *Proc
 // if found. It returns an error if search fails.
-func (d *DLL) FindProc(name string) (proc *Proc, err Error) {
+func (d *DLL) FindProc(name string) (proc *Proc, err error) {
        a, e := getprocaddress(uintptr(d.Handle), StringBytePtr(name))
        if e != 0 {
                return nil, &DLLError{
@@ -160,7 +155,7 @@ type LazyDLL struct {
 
 // Load loads DLL file d.Name into memory. It returns an error if fails.
 // Load will not try to load DLL, if it is already loaded into memory.
-func (d *LazyDLL) Load() Error {
+func (d *LazyDLL) Load() error {
        if d.dll == nil {
                d.mu.Lock()
                defer d.mu.Unlock()
@@ -211,7 +206,7 @@ type LazyProc struct {
 // Find searches DLL for procedure named p.Name. It returns
 // an error if search fails. Find will not search procedure,
 // if it is already found and loaded into memory.
-func (p *LazyProc) Find() Error {
+func (p *LazyProc) Find() error {
        if p.proc == nil {
                p.mu.Lock()
                defer p.mu.Unlock()