Some minor error handling fixes.
This commit is contained in:
parent
28e474f91f
commit
15ec07ab1a
|
@ -166,8 +166,8 @@ func (this *Document) LoadFile(filename string) (err os.Error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Document) LoadUri(uri string) (err os.Error) {
|
func (this *Document) LoadUri(uri string) (err os.Error) {
|
||||||
r, _, err := http.Get(uri)
|
var r *http.Response
|
||||||
if err != nil {
|
if r, _, err = http.Get(uri); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,8 +178,7 @@ func (this *Document) LoadUri(uri string) (err os.Error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = this.LoadString(string(b))
|
return this.LoadString(string(b))
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Document) LoadStream(r io.Reader) (err os.Error) {
|
func (this *Document) LoadStream(r io.Reader) (err os.Error) {
|
||||||
|
@ -193,8 +192,7 @@ func (this *Document) LoadStream(r io.Reader) (err os.Error) {
|
||||||
buf.Write(s)
|
buf.Write(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = this.LoadString(buf.String())
|
return this.LoadString(buf.String())
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// *****************************************************************************
|
// *****************************************************************************
|
||||||
|
@ -220,10 +218,10 @@ func (this *Document) SaveString() (s string, err os.Error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Document) SaveStream(w io.Writer) (err os.Error) {
|
func (this *Document) SaveStream(w io.Writer) (err os.Error) {
|
||||||
s, err := this.SaveString()
|
var s string
|
||||||
if err != nil {
|
if s, err = this.SaveString(); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.Write([]byte(s))
|
_, err = w.Write([]byte(s))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,11 +49,11 @@ func EntityToUtf8(entity string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
var arr [4]byte
|
var arr [4]byte
|
||||||
if size := utf8.EncodeRune(arr[0:], num); size == 0 {
|
if size := utf8.EncodeRune(arr[:], num); size == 0 {
|
||||||
return "&#" + entity + ";"
|
return "&#" + entity + ";"
|
||||||
}
|
}
|
||||||
|
|
||||||
return string(arr[0:])
|
return string(arr[:])
|
||||||
}
|
}
|
||||||
|
|
||||||
// Converts a single Go utf8-token to a Html entity.
|
// Converts a single Go utf8-token to a Html entity.
|
||||||
|
|
Loading…
Reference in New Issue