@@ -234,7 +234,7 @@ func (c *Consistency) UnmarshalText(text []byte) error {
234
234
case "LOCAL_ONE" :
235
235
* c = LocalOne
236
236
default :
237
- return fmt .Errorf ("invalid consistency %q" , string (text ))
237
+ return fmt .Errorf ("gocql: invalid consistency %q" , string (text ))
238
238
}
239
239
240
240
return nil
@@ -295,7 +295,7 @@ func (s *SerialConsistency) UnmarshalText(text []byte) error {
295
295
case "LOCAL_SERIAL" :
296
296
* s = LocalSerial
297
297
default :
298
- return fmt .Errorf ("invalid consistency %q" , string (text ))
298
+ return fmt .Errorf ("gocql: invalid consistency %q" , string (text ))
299
299
}
300
300
301
301
return nil
@@ -306,7 +306,7 @@ const (
306
306
)
307
307
308
308
var (
309
- ErrFrameTooBig = errors .New ("frame length is bigger than the maximum allowed" )
309
+ ErrFrameTooBig = errors .New ("gocql: frame length is bigger than the maximum allowed" )
310
310
)
311
311
312
312
const maxFrameHeaderSize = 9
@@ -449,15 +449,15 @@ func readHeader(r io.Reader, p []byte) (head frameHeader, err error) {
449
449
450
450
if version > protoVersion2 {
451
451
if len (p ) != 9 {
452
- return frameHeader {}, fmt .Errorf ("not enough bytes to read header require 9 got: %d" , len (p ))
452
+ return frameHeader {}, fmt .Errorf ("gocql: not enough bytes to read header require 9 got: %d" , len (p ))
453
453
}
454
454
455
455
head .stream = int (int16 (p [2 ])<< 8 | int16 (p [3 ]))
456
456
head .op = frameOp (p [4 ])
457
457
head .length = int (readInt (p [5 :]))
458
458
} else {
459
459
if len (p ) != 8 {
460
- return frameHeader {}, fmt .Errorf ("not enough bytes to read header require 8 got: %d" , len (p ))
460
+ return frameHeader {}, fmt .Errorf ("gocql: not enough bytes to read header require 8 got: %d" , len (p ))
461
461
}
462
462
463
463
head .stream = int (int8 (p [2 ]))
@@ -481,12 +481,12 @@ func (f *framer) payload() {
481
481
// reads a frame form the wire into the framers buffer
482
482
func (f * framer ) readFrame (r io.Reader , head * frameHeader ) error {
483
483
if head .length < 0 {
484
- return fmt .Errorf ("frame body length can not be less than 0: %d" , head .length )
484
+ return fmt .Errorf ("gocql: frame body length can not be less than 0: %d" , head .length )
485
485
} else if head .length > maxFrameSize {
486
486
// need to free up the connection to be used again
487
487
_ , err := io .CopyN (ioutil .Discard , r , int64 (head .length ))
488
488
if err != nil {
489
- return fmt .Errorf ("error whilst trying to discard frame with invalid length: %v " , err )
489
+ return fmt .Errorf ("gocql: error whilst trying to discard frame with invalid length: %w " , err )
490
490
}
491
491
return ErrFrameTooBig
492
492
}
@@ -501,7 +501,7 @@ func (f *framer) readFrame(r io.Reader, head *frameHeader) error {
501
501
// assume the underlying reader takes care of timeouts and retries
502
502
n , err := io .ReadFull (r , f .buf )
503
503
if err != nil {
504
- return fmt .Errorf ("unable to read frame body: read %d/%d bytes: %v " , n , head .length , err )
504
+ return fmt .Errorf ("gocql: unable to read frame body: read %d/%d bytes: %w " , n , head .length , err )
505
505
}
506
506
507
507
if head .flags & flagCompress == flagCompress {
@@ -511,7 +511,7 @@ func (f *framer) readFrame(r io.Reader, head *frameHeader) error {
511
511
512
512
f .buf , err = f .compres .Decode (f .buf )
513
513
if err != nil {
514
- return err
514
+ return fmt . Errorf ( "gocql: %w" , err )
515
515
}
516
516
}
517
517
@@ -687,7 +687,7 @@ func (f *framer) parseErrorFrame() frame {
687
687
// TODO(zariel): we should have some distinct types for these errors
688
688
return errD
689
689
default :
690
- panic (fmt .Errorf ("unknown error code: 0x%x" , errD .code ))
690
+ panic (fmt .Errorf ("gocql: unknown error code: 0x%x" , errD .code ))
691
691
}
692
692
}
693
693
@@ -756,7 +756,7 @@ func (f *framer) finish() error {
756
756
// TODO: only compress frames which are big enough
757
757
compressed , err := f .compres .Encode (f .buf [f .headSize :])
758
758
if err != nil {
759
- return err
759
+ return fmt . Errorf ( "gocql: %w" , err )
760
760
}
761
761
762
762
f .buf = append (f .buf [:f .headSize ], compressed ... )
@@ -836,7 +836,7 @@ func (w *writePrepareFrame) buildFrame(f *framer, streamID int) error {
836
836
if f .proto > protoVersion4 {
837
837
flags |= flagWithPreparedKeyspace
838
838
} else {
839
- panic (fmt .Errorf ("the keyspace can only be set with protocol 5 or higher" ))
839
+ panic (fmt .Errorf ("gocql: the keyspace can only be set with protocol 5 or higher" ))
840
840
}
841
841
}
842
842
if f .proto > protoVersion4 {
@@ -935,7 +935,7 @@ func (f *framer) parsePreparedMetadata() preparedMetadata {
935
935
meta .flags = f .readInt ()
936
936
meta .colCount = f .readInt ()
937
937
if meta .colCount < 0 {
938
- panic (fmt .Errorf ("received negative column count: %d" , meta .colCount ))
938
+ panic (fmt .Errorf ("gocql: received negative column count: %d" , meta .colCount ))
939
939
}
940
940
meta .actualColCount = meta .colCount
941
941
@@ -1032,7 +1032,7 @@ func (f *framer) parseResultMetadata() resultMetadata {
1032
1032
meta .flags = f .readInt ()
1033
1033
meta .colCount = f .readInt ()
1034
1034
if meta .colCount < 0 {
1035
- panic (fmt .Errorf ("received negative column count: %d" , meta .colCount ))
1035
+ panic (fmt .Errorf ("gocql: received negative column count: %d" , meta .colCount ))
1036
1036
}
1037
1037
meta .actualColCount = meta .colCount
1038
1038
@@ -1119,7 +1119,7 @@ func (f *framer) parseResultRows() frame {
1119
1119
1120
1120
result .numRows = f .readInt ()
1121
1121
if result .numRows < 0 {
1122
- panic (fmt .Errorf ("invalid row_count in result frame: %d" , result .numRows ))
1122
+ panic (fmt .Errorf ("gocql: invalid row_count in result frame: %d" , result .numRows ))
1123
1123
}
1124
1124
1125
1125
return result
@@ -1487,7 +1487,7 @@ func (f *framer) writeQueryParams(opts *queryParams) {
1487
1487
if f .proto > protoVersion4 {
1488
1488
flags |= flagWithKeyspace
1489
1489
} else {
1490
- panic (fmt .Errorf ("the keyspace can only be set with protocol 5 or higher" ))
1490
+ panic (fmt .Errorf ("gocql: the keyspace can only be set with protocol 5 or higher" ))
1491
1491
}
1492
1492
}
1493
1493
@@ -1750,7 +1750,7 @@ func (f *framer) writeRegisterFrame(streamID int, w *writeRegisterFrame) error {
1750
1750
1751
1751
func (f * framer ) readByte () byte {
1752
1752
if len (f .buf ) < 1 {
1753
- panic (fmt .Errorf ("not enough bytes in buffer to read byte require 1 got: %d" , len (f .buf )))
1753
+ panic (fmt .Errorf ("gocql: not enough bytes in buffer to read byte require 1 got: %d" , len (f .buf )))
1754
1754
}
1755
1755
1756
1756
b := f .buf [0 ]
@@ -1760,7 +1760,7 @@ func (f *framer) readByte() byte {
1760
1760
1761
1761
func (f * framer ) readInt () (n int ) {
1762
1762
if len (f .buf ) < 4 {
1763
- panic (fmt .Errorf ("not enough bytes in buffer to read int require 4 got: %d" , len (f .buf )))
1763
+ panic (fmt .Errorf ("gocql: not enough bytes in buffer to read int require 4 got: %d" , len (f .buf )))
1764
1764
}
1765
1765
1766
1766
n = int (int32 (f .buf [0 ])<< 24 | int32 (f .buf [1 ])<< 16 | int32 (f .buf [2 ])<< 8 | int32 (f .buf [3 ]))
@@ -1770,7 +1770,7 @@ func (f *framer) readInt() (n int) {
1770
1770
1771
1771
func (f * framer ) readShort () (n uint16 ) {
1772
1772
if len (f .buf ) < 2 {
1773
- panic (fmt .Errorf ("not enough bytes in buffer to read short require 2 got: %d" , len (f .buf )))
1773
+ panic (fmt .Errorf ("gocql: not enough bytes in buffer to read short require 2 got: %d" , len (f .buf )))
1774
1774
}
1775
1775
n = uint16 (f .buf [0 ])<< 8 | uint16 (f .buf [1 ])
1776
1776
f .buf = f .buf [2 :]
@@ -1781,7 +1781,7 @@ func (f *framer) readString() (s string) {
1781
1781
size := f .readShort ()
1782
1782
1783
1783
if len (f .buf ) < int (size ) {
1784
- panic (fmt .Errorf ("not enough bytes in buffer to read string require %d got: %d" , size , len (f .buf )))
1784
+ panic (fmt .Errorf ("gocql: not enough bytes in buffer to read string require %d got: %d" , size , len (f .buf )))
1785
1785
}
1786
1786
1787
1787
s = string (f .buf [:size ])
@@ -1793,7 +1793,7 @@ func (f *framer) readLongString() (s string) {
1793
1793
size := f .readInt ()
1794
1794
1795
1795
if len (f .buf ) < size {
1796
- panic (fmt .Errorf ("not enough bytes in buffer to read long string require %d got: %d" , size , len (f .buf )))
1796
+ panic (fmt .Errorf ("gocql: not enough bytes in buffer to read long string require %d got: %d" , size , len (f .buf )))
1797
1797
}
1798
1798
1799
1799
s = string (f .buf [:size ])
@@ -1803,7 +1803,7 @@ func (f *framer) readLongString() (s string) {
1803
1803
1804
1804
func (f * framer ) readUUID () * UUID {
1805
1805
if len (f .buf ) < 16 {
1806
- panic (fmt .Errorf ("not enough bytes in buffer to read uuid require %d got: %d" , 16 , len (f .buf )))
1806
+ panic (fmt .Errorf ("gocql: not enough bytes in buffer to read uuid require %d got: %d" , 16 , len (f .buf )))
1807
1807
}
1808
1808
1809
1809
// TODO: how to handle this error, if it is a uuid, then sureley, problems?
@@ -1830,7 +1830,7 @@ func (f *framer) readBytesInternal() ([]byte, error) {
1830
1830
}
1831
1831
1832
1832
if len (f .buf ) < size {
1833
- return nil , fmt .Errorf ("not enough bytes in buffer to read bytes require %d got: %d" , size , len (f .buf ))
1833
+ return nil , fmt .Errorf ("gocql: not enough bytes in buffer to read bytes require %d got: %d" , size , len (f .buf ))
1834
1834
}
1835
1835
1836
1836
l := f .buf [:size ]
@@ -1851,7 +1851,7 @@ func (f *framer) readBytes() []byte {
1851
1851
func (f * framer ) readShortBytes () []byte {
1852
1852
size := f .readShort ()
1853
1853
if len (f .buf ) < int (size ) {
1854
- panic (fmt .Errorf ("not enough bytes in buffer to read short bytes: require %d got %d" , size , len (f .buf )))
1854
+ panic (fmt .Errorf ("gocql: not enough bytes in buffer to read short bytes: require %d got %d" , size , len (f .buf )))
1855
1855
}
1856
1856
1857
1857
l := f .buf [:size ]
@@ -1862,18 +1862,18 @@ func (f *framer) readShortBytes() []byte {
1862
1862
1863
1863
func (f * framer ) readInetAdressOnly () net.IP {
1864
1864
if len (f .buf ) < 1 {
1865
- panic (fmt .Errorf ("not enough bytes in buffer to read inet size require %d got: %d" , 1 , len (f .buf )))
1865
+ panic (fmt .Errorf ("gocql: not enough bytes in buffer to read inet size require %d got: %d" , 1 , len (f .buf )))
1866
1866
}
1867
1867
1868
1868
size := f .buf [0 ]
1869
1869
f .buf = f .buf [1 :]
1870
1870
1871
1871
if ! (size == 4 || size == 16 ) {
1872
- panic (fmt .Errorf ("invalid IP size: %d" , size ))
1872
+ panic (fmt .Errorf ("gocql: invalid IP size: %d" , size ))
1873
1873
}
1874
1874
1875
1875
if len (f .buf ) < 1 {
1876
- panic (fmt .Errorf ("not enough bytes in buffer to read inet require %d got: %d" , size , len (f .buf )))
1876
+ panic (fmt .Errorf ("gocql: not enough bytes in buffer to read inet require %d got: %d" , size , len (f .buf )))
1877
1877
}
1878
1878
1879
1879
ip := make ([]byte , size )
0 commit comments