The Go Programming Language

Source file src/pkg/os/error.go

     1	// Copyright 2009 The Go Authors. All rights reserved.
     2	// Use of this source code is governed by a BSD-style
     3	// license that can be found in the LICENSE file.
     4	
     5	package os
     6	
     7	// An Error can represent any printable error condition.
     8	type Error interface {
     9		String() string
    10	}
    11	
    12	// // errorString is a helper type used by NewError.
    13	type errorString string
    14	
    15	func (e errorString) String() string { return string(e) }
    16	
    17	// Note: If the name of the function NewError changes,
    18	// pkg/go/doc/doc.go should be adjusted since it hardwires
    19	// this name in a heuristic.
    20	
    21	// // NewError returns a new error with error.String() == s.
    22	func NewError(s string) Error { return errorString(s) }
    23	
    24	// PathError records an error and the operation and file path that caused it.
    25	type PathError struct {
    26		Op    string
    27		Path  string
    28		Error Error
    29	}
    30	
    31	func (e *PathError) String() string { return e.Op + " " + e.Path + ": " + e.Error.String() }

release.r60.3. Except as noted, this content is licensed under a Creative Commons Attribution 3.0 License.