diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2015-08-25 14:19:33 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2015-08-25 14:19:33 -0600 |
commit | 75c89781ab3ed908307920e4acdeb86f275f2faa (patch) | |
tree | e9cf634a2d1990949b915bc17e6d48b8c3f4322a /src/nslcd-proto/util.go |
initial commit
Diffstat (limited to 'src/nslcd-proto/util.go')
-rw-r--r-- | src/nslcd-proto/util.go | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/nslcd-proto/util.go b/src/nslcd-proto/util.go new file mode 100644 index 0000000..ec74df2 --- /dev/null +++ b/src/nslcd-proto/util.go @@ -0,0 +1,47 @@ +package nslcd_proto + +import "io" + +type NslcdError string +func (o NslcdError) Error() string { + return string(o) +} + +type NslcdObject interface { + NslcdWrite(fd io.Writer) +} +type NslcdObjectPtr interface { + NslcdRead(fd io.Reader) +} + +func Write(fd io.Writer, data interface{}) (err error) { + err = nil + defer func() { + if r := recover(); r != nil { + switch r := r.(type) { + case error: + err = r + default: + panic(r) + } + } + }() + write(fd, data) + return +} + +func Read(fd io.Reader, data interface{}) (err error) { + err = nil + defer func() { + if r := recover(); r != nil { + switch r := r.(type) { + case error: + err = r + default: + panic(r) + } + } + }() + read(fd, data); + return +} |