@@ -254,7 +254,7 @@ func (c *Consistency) UnmarshalText(text []byte) error {
254
254
case "LOCAL_ONE" :
255
255
* c = LocalOne
256
256
default :
257
- return fmt .Errorf ("invalid consistency %q" , string (text ))
257
+ return fmt .Errorf ("gocql: invalid consistency %q" , string (text ))
258
258
}
259
259
260
260
return nil
@@ -304,7 +304,7 @@ func (s *SerialConsistency) UnmarshalText(text []byte) error {
304
304
case "LOCAL_SERIAL" :
305
305
* s = LocalSerial
306
306
default :
307
- return fmt .Errorf ("invalid consistency %q" , string (text ))
307
+ return fmt .Errorf ("gocql: invalid consistency %q" , string (text ))
308
308
}
309
309
310
310
return nil
@@ -315,7 +315,7 @@ const (
315
315
)
316
316
317
317
var (
318
- ErrFrameTooBig = errors .New ("frame length is bigger than the maximum allowed" )
318
+ ErrFrameTooBig = errors .New ("gocql: frame length is bigger than the maximum allowed" )
319
319
)
320
320
321
321
const maxFrameHeaderSize = 9
@@ -458,15 +458,15 @@ func readHeader(r io.Reader, p []byte) (head frameHeader, err error) {
458
458
459
459
if version > protoVersion2 {
460
460
if len (p ) != 9 {
461
- return frameHeader {}, fmt .Errorf ("not enough bytes to read header require 9 got: %d" , len (p ))
461
+ return frameHeader {}, fmt .Errorf ("gocql: not enough bytes to read header require 9 got: %d" , len (p ))
462
462
}
463
463
464
464
head .stream = int (int16 (p [2 ])<< 8 | int16 (p [3 ]))
465
465
head .op = frameOp (p [4 ])
466
466
head .length = int (readInt (p [5 :]))
467
467
} else {
468
468
if len (p ) != 8 {
469
- return frameHeader {}, fmt .Errorf ("not enough bytes to read header require 8 got: %d" , len (p ))
469
+ return frameHeader {}, fmt .Errorf ("gocql: not enough bytes to read header require 8 got: %d" , len (p ))
470
470
}
471
471
472
472
head .stream = int (int8 (p [2 ]))
@@ -490,12 +490,12 @@ func (f *framer) payload() {
490
490
// reads a frame form the wire into the framers buffer
491
491
func (f * framer ) readFrame (r io.Reader , head * frameHeader ) error {
492
492
if head .length < 0 {
493
- return fmt .Errorf ("frame body length can not be less than 0: %d" , head .length )
493
+ return fmt .Errorf ("gocql: frame body length can not be less than 0: %d" , head .length )
494
494
} else if head .length > maxFrameSize {
495
495
// need to free up the connection to be used again
496
496
_ , err := io .CopyN (ioutil .Discard , r , int64 (head .length ))
497
497
if err != nil {
498
- return fmt .Errorf ("error whilst trying to discard frame with invalid length: %v " , err )
498
+ return fmt .Errorf ("gocql: error whilst trying to discard frame with invalid length: %w " , err )
499
499
}
500
500
return ErrFrameTooBig
501
501
}
@@ -510,7 +510,7 @@ func (f *framer) readFrame(r io.Reader, head *frameHeader) error {
510
510
// assume the underlying reader takes care of timeouts and retries
511
511
n , err := io .ReadFull (r , f .buf )
512
512
if err != nil {
513
- return fmt .Errorf ("unable to read frame body: read %d/%d bytes: %v " , n , head .length , err )
513
+ return fmt .Errorf ("gocql: unable to read frame body: read %d/%d bytes: %w " , n , head .length , err )
514
514
}
515
515
516
516
if head .flags & flagCompress == flagCompress {
@@ -520,7 +520,7 @@ func (f *framer) readFrame(r io.Reader, head *frameHeader) error {
520
520
521
521
f .buf , err = f .compres .Decode (f .buf )
522
522
if err != nil {
523
- return err
523
+ return fmt . Errorf ( "gocql: %w" , err )
524
524
}
525
525
}
526
526
@@ -696,7 +696,7 @@ func (f *framer) parseErrorFrame() frame {
696
696
// TODO(zariel): we should have some distinct types for these errors
697
697
return errD
698
698
default :
699
- panic (fmt .Errorf ("unknown error code: 0x%x" , errD .code ))
699
+ panic (fmt .Errorf ("gocql: unknown error code: 0x%x" , errD .code ))
700
700
}
701
701
}
702
702
@@ -765,7 +765,7 @@ func (f *framer) finish() error {
765
765
// TODO: only compress frames which are big enough
766
766
compressed , err := f .compres .Encode (f .buf [f .headSize :])
767
767
if err != nil {
768
- return err
768
+ return fmt . Errorf ( "gocql: %w" , err )
769
769
}
770
770
771
771
f .buf = append (f .buf [:f .headSize ], compressed ... )
@@ -845,7 +845,7 @@ func (w *writePrepareFrame) buildFrame(f *framer, streamID int) error {
845
845
if f .proto > protoVersion4 {
846
846
flags |= flagWithPreparedKeyspace
847
847
} else {
848
- panic (fmt .Errorf ("the keyspace can only be set with protocol 5 or higher" ))
848
+ panic (fmt .Errorf ("gocql: the keyspace can only be set with protocol 5 or higher" ))
849
849
}
850
850
}
851
851
if f .proto > protoVersion4 {
@@ -944,7 +944,7 @@ func (f *framer) parsePreparedMetadata() preparedMetadata {
944
944
meta .flags = f .readInt ()
945
945
meta .colCount = f .readInt ()
946
946
if meta .colCount < 0 {
947
- panic (fmt .Errorf ("received negative column count: %d" , meta .colCount ))
947
+ panic (fmt .Errorf ("gocql: received negative column count: %d" , meta .colCount ))
948
948
}
949
949
meta .actualColCount = meta .colCount
950
950
@@ -1041,7 +1041,7 @@ func (f *framer) parseResultMetadata() resultMetadata {
1041
1041
meta .flags = f .readInt ()
1042
1042
meta .colCount = f .readInt ()
1043
1043
if meta .colCount < 0 {
1044
- panic (fmt .Errorf ("received negative column count: %d" , meta .colCount ))
1044
+ panic (fmt .Errorf ("gocql: received negative column count: %d" , meta .colCount ))
1045
1045
}
1046
1046
meta .actualColCount = meta .colCount
1047
1047
@@ -1128,7 +1128,7 @@ func (f *framer) parseResultRows() frame {
1128
1128
1129
1129
result .numRows = f .readInt ()
1130
1130
if result .numRows < 0 {
1131
- panic (fmt .Errorf ("invalid row_count in result frame: %d" , result .numRows ))
1131
+ panic (fmt .Errorf ("gocql: invalid row_count in result frame: %d" , result .numRows ))
1132
1132
}
1133
1133
1134
1134
return result
@@ -1496,7 +1496,7 @@ func (f *framer) writeQueryParams(opts *queryParams) {
1496
1496
if f .proto > protoVersion4 {
1497
1497
flags |= flagWithKeyspace
1498
1498
} else {
1499
- panic (fmt .Errorf ("the keyspace can only be set with protocol 5 or higher" ))
1499
+ panic (fmt .Errorf ("gocql: the keyspace can only be set with protocol 5 or higher" ))
1500
1500
}
1501
1501
}
1502
1502
@@ -1759,7 +1759,7 @@ func (f *framer) writeRegisterFrame(streamID int, w *writeRegisterFrame) error {
1759
1759
1760
1760
func (f * framer ) readByte () byte {
1761
1761
if len (f .buf ) < 1 {
1762
- panic (fmt .Errorf ("not enough bytes in buffer to read byte require 1 got: %d" , len (f .buf )))
1762
+ panic (fmt .Errorf ("gocql: not enough bytes in buffer to read byte require 1 got: %d" , len (f .buf )))
1763
1763
}
1764
1764
1765
1765
b := f .buf [0 ]
@@ -1769,7 +1769,7 @@ func (f *framer) readByte() byte {
1769
1769
1770
1770
func (f * framer ) readInt () (n int ) {
1771
1771
if len (f .buf ) < 4 {
1772
- panic (fmt .Errorf ("not enough bytes in buffer to read int require 4 got: %d" , len (f .buf )))
1772
+ panic (fmt .Errorf ("gocql: not enough bytes in buffer to read int require 4 got: %d" , len (f .buf )))
1773
1773
}
1774
1774
1775
1775
n = int (int32 (f .buf [0 ])<< 24 | int32 (f .buf [1 ])<< 16 | int32 (f .buf [2 ])<< 8 | int32 (f .buf [3 ]))
@@ -1779,7 +1779,7 @@ func (f *framer) readInt() (n int) {
1779
1779
1780
1780
func (f * framer ) readShort () (n uint16 ) {
1781
1781
if len (f .buf ) < 2 {
1782
- panic (fmt .Errorf ("not enough bytes in buffer to read short require 2 got: %d" , len (f .buf )))
1782
+ panic (fmt .Errorf ("gocql: not enough bytes in buffer to read short require 2 got: %d" , len (f .buf )))
1783
1783
}
1784
1784
n = uint16 (f .buf [0 ])<< 8 | uint16 (f .buf [1 ])
1785
1785
f .buf = f .buf [2 :]
@@ -1790,7 +1790,7 @@ func (f *framer) readString() (s string) {
1790
1790
size := f .readShort ()
1791
1791
1792
1792
if len (f .buf ) < int (size ) {
1793
- panic (fmt .Errorf ("not enough bytes in buffer to read string require %d got: %d" , size , len (f .buf )))
1793
+ panic (fmt .Errorf ("gocql: not enough bytes in buffer to read string require %d got: %d" , size , len (f .buf )))
1794
1794
}
1795
1795
1796
1796
s = string (f .buf [:size ])
@@ -1802,7 +1802,7 @@ func (f *framer) readLongString() (s string) {
1802
1802
size := f .readInt ()
1803
1803
1804
1804
if len (f .buf ) < size {
1805
- panic (fmt .Errorf ("not enough bytes in buffer to read long string require %d got: %d" , size , len (f .buf )))
1805
+ panic (fmt .Errorf ("gocql: not enough bytes in buffer to read long string require %d got: %d" , size , len (f .buf )))
1806
1806
}
1807
1807
1808
1808
s = string (f .buf [:size ])
@@ -1812,7 +1812,7 @@ func (f *framer) readLongString() (s string) {
1812
1812
1813
1813
func (f * framer ) readUUID () * UUID {
1814
1814
if len (f .buf ) < 16 {
1815
- panic (fmt .Errorf ("not enough bytes in buffer to read uuid require %d got: %d" , 16 , len (f .buf )))
1815
+ panic (fmt .Errorf ("gocql: not enough bytes in buffer to read uuid require %d got: %d" , 16 , len (f .buf )))
1816
1816
}
1817
1817
1818
1818
// TODO: how to handle this error, if it is a uuid, then sureley, problems?
@@ -1839,7 +1839,7 @@ func (f *framer) readBytesInternal() ([]byte, error) {
1839
1839
}
1840
1840
1841
1841
if len (f .buf ) < size {
1842
- return nil , fmt .Errorf ("not enough bytes in buffer to read bytes require %d got: %d" , size , len (f .buf ))
1842
+ return nil , fmt .Errorf ("gocql: not enough bytes in buffer to read bytes require %d got: %d" , size , len (f .buf ))
1843
1843
}
1844
1844
1845
1845
l := f .buf [:size ]
@@ -1860,7 +1860,7 @@ func (f *framer) readBytes() []byte {
1860
1860
func (f * framer ) readShortBytes () []byte {
1861
1861
size := f .readShort ()
1862
1862
if len (f .buf ) < int (size ) {
1863
- panic (fmt .Errorf ("not enough bytes in buffer to read short bytes: require %d got %d" , size , len (f .buf )))
1863
+ panic (fmt .Errorf ("gocql: not enough bytes in buffer to read short bytes: require %d got %d" , size , len (f .buf )))
1864
1864
}
1865
1865
1866
1866
l := f .buf [:size ]
@@ -1871,18 +1871,18 @@ func (f *framer) readShortBytes() []byte {
1871
1871
1872
1872
func (f * framer ) readInetAdressOnly () net.IP {
1873
1873
if len (f .buf ) < 1 {
1874
- panic (fmt .Errorf ("not enough bytes in buffer to read inet size require %d got: %d" , 1 , len (f .buf )))
1874
+ panic (fmt .Errorf ("gocql: not enough bytes in buffer to read inet size require %d got: %d" , 1 , len (f .buf )))
1875
1875
}
1876
1876
1877
1877
size := f .buf [0 ]
1878
1878
f .buf = f .buf [1 :]
1879
1879
1880
1880
if ! (size == 4 || size == 16 ) {
1881
- panic (fmt .Errorf ("invalid IP size: %d" , size ))
1881
+ panic (fmt .Errorf ("gocql: invalid IP size: %d" , size ))
1882
1882
}
1883
1883
1884
1884
if len (f .buf ) < 1 {
1885
- panic (fmt .Errorf ("not enough bytes in buffer to read inet require %d got: %d" , size , len (f .buf )))
1885
+ panic (fmt .Errorf ("gocql: not enough bytes in buffer to read inet require %d got: %d" , size , len (f .buf )))
1886
1886
}
1887
1887
1888
1888
ip := make ([]byte , size )
0 commit comments