2008-09-11 14:03:46 -06:00
|
|
|
// Copyright 2009 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package os
|
|
|
|
|
2009-04-17 01:08:24 -06:00
|
|
|
// An Error can represent any printable error condition.
|
|
|
|
type Error interface {
|
2009-12-15 16:40:16 -07:00
|
|
|
String() string
|
2009-04-17 01:08:24 -06:00
|
|
|
}
|
|
|
|
|
2011-06-22 11:52:47 -06:00
|
|
|
// // errorString is a helper type used by NewError.
|
|
|
|
type errorString string
|
2009-10-06 20:40:35 -06:00
|
|
|
|
2011-06-22 11:52:47 -06:00
|
|
|
func (e errorString) String() string { return string(e) }
|
2009-04-17 01:08:24 -06:00
|
|
|
|
2009-10-15 10:24:19 -06:00
|
|
|
// Note: If the name of the function NewError changes,
|
|
|
|
// pkg/go/doc/doc.go should be adjusted since it hardwires
|
|
|
|
// this name in a heuristic.
|
|
|
|
|
2011-06-22 11:52:47 -06:00
|
|
|
// // NewError returns a new error with error.String() == s.
|
|
|
|
func NewError(s string) Error { return errorString(s) }
|
2009-05-08 15:40:20 -06:00
|
|
|
|
2009-06-25 21:24:55 -06:00
|
|
|
// PathError records an error and the operation and file path that caused it.
|
|
|
|
type PathError struct {
|
2009-12-15 16:40:16 -07:00
|
|
|
Op string
|
|
|
|
Path string
|
|
|
|
Error Error
|
2009-06-25 21:24:55 -06:00
|
|
|
}
|
|
|
|
|
2009-12-15 16:40:16 -07:00
|
|
|
func (e *PathError) String() string { return e.Op + " " + e.Path + ": " + e.Error.String() }
|