From 4fc0338d2a6a85f247aa0bc8de7a19f700f1d131 Mon Sep 17 00:00:00 2001 From: Julien Schmidt Date: Sat, 9 Nov 2013 17:20:45 +0100 Subject: [PATCH] errors: Export MySQLWarning For documentation purposes --- errors.go | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/errors.go b/errors.go index 1f4b8c0ac..811fe98fe 100644 --- a/errors.go +++ b/errors.go @@ -26,7 +26,7 @@ var ( errPktTooLarge = errors.New("Packet for query is too large. You can change this value on the server by adjusting the 'max_allowed_packet' variable.") ) -// error type which represents a single MySQL error +// MySQLError is an error type which represents a single MySQL error type MySQLError struct { Number uint16 Message string @@ -36,8 +36,9 @@ func (me *MySQLError) Error() string { return fmt.Sprintf("Error %d: %s", me.Number, me.Message) } -// error type which represents a group of one or more MySQL warnings -type MySQLWarnings []mysqlWarning +// MySQLWarnings is an error type which represents a group of one or more MySQL +// warnings +type MySQLWarnings []MysqlWarning func (mws MySQLWarnings) Error() string { var msg string @@ -45,13 +46,19 @@ func (mws MySQLWarnings) Error() string { if i > 0 { msg += "\r\n" } - msg += fmt.Sprintf("%s %s: %s", warning.Level, warning.Code, warning.Message) + msg += fmt.Sprintf( + "%s %s: %s", + warning.Level, + warning.Code, + warning.Message, + ) } return msg } -// error type which represents a single MySQL warning -type mysqlWarning struct { +// MysqlWarning is an error type which represents a single MySQL warning. +// Warnings are returned in groups only. See MySQLWarnings +type MysqlWarning struct { Level string Code string Message string @@ -66,7 +73,7 @@ func (mc *mysqlConn) getWarnings() (err error) { var warnings = MySQLWarnings{} var values = make([]driver.Value, 3) - var warning mysqlWarning + var warning MysqlWarning var raw []byte var ok bool @@ -74,7 +81,7 @@ func (mc *mysqlConn) getWarnings() (err error) { err = rows.Next(values) switch err { case nil: - warning = mysqlWarning{} + warning = MysqlWarning{} if raw, ok = values[0].([]byte); ok { warning.Level = string(raw)