forked from ruiaylin/pgparser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pgnotice.go
33 lines (29 loc) · 1.11 KB
/
pgnotice.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright 2020 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.
package pgnotice
import (
"github.com/ruiaylin/pgparser/pgwire/pgcode"
"github.com/ruiaylin/pgparser/pgwire/pgerror"
"github.com/cockroachdb/errors"
)
// Newf generates a Notice with a format string.
func Newf(format string, args ...interface{}) error {
err := errors.NewWithDepthf(1, format, args...)
err = pgerror.WithCandidateCode(err, pgcode.SuccessfulCompletion)
err = pgerror.WithSeverity(err, "NOTICE")
return err
}
// NewWithSeverityf generates a Notice with a format string and severity.
func NewWithSeverityf(severity string, format string, args ...interface{}) error {
err := errors.NewWithDepthf(1, format, args...)
err = pgerror.WithCandidateCode(err, pgcode.SuccessfulCompletion)
err = pgerror.WithSeverity(err, severity)
return err
}