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