github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/sql/pgwire/pgnotice/pgnotice.go (about)

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