mirror of
https://github.com/zjdyzww/harness.git
synced 2026-09-28 06:13:43 +08:00
* 6d0287 update comments to use space * 1ce37b drop additionalKiB param * 8a70c5 add nolint for gosec * 9325b7 test: [CODE-5494]: assert the fail-open storage check actually logs * 7b4dd8 test: [CODE-5494]: cover storage-quota error translation and restore blocking * 1a0413 fix: [CODE-5494]: don't swallow non-quota storage measurement errors * 4094cf block repo creation, fork, imports when storage is overlimit * 15582e add sentinel errors for limited storage
36 lines
1.0 KiB
Go
36 lines
1.0 KiB
Go
// Copyright 2023 Harness, Inc.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
package errors
|
|
|
|
import "errors"
|
|
|
|
func New(text string) error {
|
|
return errors.New(text)
|
|
}
|
|
|
|
func Is(err error, target error) bool {
|
|
return errors.Is(err, target)
|
|
}
|
|
|
|
func As(err error, target any) bool {
|
|
return errors.As(err, target)
|
|
}
|
|
|
|
// AsType is As for a single target type, so that a caller can bind the error and test it
|
|
// in one expression: quotaErr, ok := AsType[*QuotaError](err).
|
|
func AsType[T error](err error) (T, bool) {
|
|
return errors.AsType[T](err)
|
|
}
|