Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
52f071ed
Commit
52f071ed
authored
May 13, 2009
by
Rob Pike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename ParseError to Error
R=rsc DELTA=13 (6 added, 1 deleted, 6 changed) OCL=28743 CL=28746
parent
98b4f6ac
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
6 deletions
+11
-6
template.go
src/lib/template/template.go
+11
-6
No files found.
src/lib/template/template.go
View file @
52f071ed
...
...
@@ -57,6 +57,7 @@
package
template
import
(
"container/vector"
;
"fmt"
;
"io"
;
"os"
;
...
...
@@ -64,13 +65,17 @@ import (
"runtime"
;
"strings"
;
"template"
;
"container/vector"
;
)
// Errors returned during parsing. TODO: different error model for execution?
// Errors returned during parsing and execution. Users may extract the information and reformat
// if they desire.
type
Error
struct
{
Line
int
;
Msg
string
;
}
type
ParseError
struct
{
os
.
ErrorString
func
(
e
*
Error
)
String
()
string
{
return
fmt
.
Sprintf
(
"line %d: %s"
,
e
.
Line
,
e
.
Msg
)
}
// Most of the literals are aces.
...
...
@@ -181,7 +186,7 @@ func New(fmap FormatterMap) *Template {
// Generic error handler, called only from execError or parseError.
func
error
(
errors
chan
os
.
Error
,
line
int
,
err
string
,
args
...
)
{
errors
<-
ParseError
{
os
.
ErrorString
(
fmt
.
Sprintf
(
"line %d: %s"
,
line
,
fmt
.
Sprintf
(
err
,
args
))
)};
errors
<-
&
Error
{
line
,
fmt
.
Sprintf
(
err
,
args
)};
runtime
.
Goexit
();
}
...
...
@@ -756,7 +761,7 @@ func validDelim(d []byte) bool {
// the error.
func
(
t
*
Template
)
Parse
(
s
string
)
os
.
Error
{
if
!
validDelim
(
t
.
ldelim
)
||
!
validDelim
(
t
.
rdelim
)
{
return
ParseError
{
os
.
ErrorString
(
fmt
.
Sprintf
(
"bad delimiter strings %q %q"
,
t
.
ldelim
,
t
.
rdelim
)
)}
return
&
Error
{
1
,
fmt
.
Sprintf
(
"bad delimiter strings %q %q"
,
t
.
ldelim
,
t
.
rdelim
)}
}
t
.
buf
=
io
.
StringBytes
(
s
);
t
.
p
=
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment