aboutsummaryrefslogtreecommitdiff
path: root/forged/internal/misc/panic.go
blob: 34c49c50d8f6729c20f9ffd9e7060acdd8c17c1b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

// SPDX-License-Identifier: AGPL-3.0-only
// SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org>

package misc

// FirstOrPanic returns the value or panics if the error is non-nil.
func FirstOrPanic[T any](v T, err error) T {
	if err != nil {
		panic(err)
	}
	return v
}

// NoneOrPanic panics if the provided error is non-nil.
func NoneOrPanic(err error) {
	if err != nil {
		panic(err)
	}
}