github.com/cockroachdb/pebble@v1.1.1-0.20240513155919-3622ade60459/internal/base/error.go (about) 1 // Copyright 2011 The LevelDB-Go and Pebble Authors. All rights reserved. Use 2 // of this source code is governed by a BSD-style license that can be found in 3 // the LICENSE file. 4 5 package base 6 7 import "github.com/cockroachdb/errors" 8 9 // ErrNotFound means that a get or delete call did not find the requested key. 10 var ErrNotFound = errors.New("pebble: not found") 11 12 // ErrCorruption is a marker to indicate that data in a file (WAL, MANIFEST, 13 // sstable) isn't in the expected format. 14 var ErrCorruption = errors.New("pebble: corruption") 15 16 // MarkCorruptionError marks given error as a corruption error. 17 func MarkCorruptionError(err error) error { 18 if errors.Is(err, ErrCorruption) { 19 return err 20 } 21 return errors.Mark(err, ErrCorruption) 22 } 23 24 // CorruptionErrorf formats according to a format specifier and returns 25 // the string as an error value that is marked as a corruption error. 26 func CorruptionErrorf(format string, args ...interface{}) error { 27 return errors.Mark(errors.Newf(format, args...), ErrCorruption) 28 }