]> Cypherpunks repositories - gostls13.git/commitdiff
more useful error string
authorRobert Griesemer <gri@golang.org>
Wed, 20 May 2009 18:02:12 +0000 (11:02 -0700)
committerRobert Griesemer <gri@golang.org>
Wed, 20 May 2009 18:02:12 +0000 (11:02 -0700)
R=r
DELTA=5  (4 added, 0 deleted, 1 changed)
OCL=29088
CL=29090

src/lib/go/parser/parser.go

index 8663289f8b34ed8bf7aa7e3d10209743337d8e52..e320bec42fec60b80cd995f8f8267b107a37540d 100644 (file)
@@ -50,7 +50,11 @@ func (p ErrorList) Less(i, j int) bool  { return p[i].Pos.Offset < p[j].Pos.Offs
 
 
 func (p ErrorList) String() string {
-       return fmt.Sprintf("%d syntax errors", len(p));
+       switch len(p) {
+       case 0: return "unspecified error";
+       case 1: return p[0].String();
+       }
+       return fmt.Sprintf("%s (and %d more errors)", p[0].String(), len(p) - 1);
 }