Skip to content

Commit 172ee4d

Browse files
authored
Remove pingcap/errors dependency in favor of stdlib (#6)
1 parent 76eec20 commit 172ee4d

26 files changed

Lines changed: 701 additions & 655 deletions

ast/annotate.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright 2025 PingCAP, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
14+
package ast
15+
16+
import "fmt"
17+
18+
func annotate(err error, msg string) error {
19+
if err == nil {
20+
return nil
21+
}
22+
return fmt.Errorf("%s: %w", msg, err)
23+
}
24+
25+
func annotatef(err error, format string, args ...any) error {
26+
if err == nil {
27+
return nil
28+
}
29+
return fmt.Errorf("%s: %w", fmt.Sprintf(format, args...), err)
30+
}

0 commit comments

Comments
 (0)