summaryrefslogtreecommitdiff
path: root/src/pkg/go/scanner/errors.go
diff options
context:
space:
mode:
authorAustin Clements <aclements@csail.mit.edu>2009-07-30 16:58:19 -0700
committerAustin Clements <aclements@csail.mit.edu>2009-07-30 16:58:19 -0700
commite383d220bd4e700a329ac87dd8ff3fc14eb3e545 (patch)
tree48be18906a57eed3291b9c905275afed0048fb2e /src/pkg/go/scanner/errors.go
parent775a36ebf074ae48e5db28d257a7eaa9d1407955 (diff)
downloadgolang-e383d220bd4e700a329ac87dd8ff3fc14eb3e545.tar.gz
String method for token.Position. Extracted from gri's tree.
R=gri APPROVED=gri DELTA=33 (20 added, 6 deleted, 7 changed) OCL=32544 CL=32546
Diffstat (limited to 'src/pkg/go/scanner/errors.go')
-rw-r--r--src/pkg/go/scanner/errors.go15
1 files changed, 5 insertions, 10 deletions
diff --git a/src/pkg/go/scanner/errors.go b/src/pkg/go/scanner/errors.go
index 54770f020..fde211216 100644
--- a/src/pkg/go/scanner/errors.go
+++ b/src/pkg/go/scanner/errors.go
@@ -69,17 +69,12 @@ type Error struct {
func (e *Error) String() string {
- s := e.Pos.Filename;
- if s != "" {
- s += ":";
+ if e.Pos.Filename != "" || e.Pos.IsValid() {
+ // don't print "<unknown position>"
+ // TODO(gri) reconsider the semantics of Position.IsValid
+ return e.Pos.String() + ": " + e.Msg;
}
- if e.Pos.IsValid() {
- s += fmt.Sprintf("%d:%d:", e.Pos.Line, e.Pos.Column);
- }
- if s != "" {
- s += " ";
- }
- return s + e.Msg;
+ return e.Msg;
}