-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdbc.go
More file actions
30 lines (24 loc) · 908 Bytes
/
dbc.go
File metadata and controls
30 lines (24 loc) · 908 Bytes
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
//go:build debug
// +build debug
package aasx
import (
"errors"
)
// ErrPreconditionViolation is returned when a precondition check fails.
var ErrPreconditionViolation = errors.New("precondition violation")
// ErrPostconditionViolation is returned when a postcondition check fails.
var ErrPostconditionViolation = errors.New("postcondition violation")
// Require checks a precondition and panics with the given message if it fails.
// Use this for validating function arguments and entry conditions.
func Require(condition bool, message string) {
if !condition {
panic(ErrPreconditionViolation.Error() + ": " + message)
}
}
// Ensure checks a postcondition and panics with the given message if it fails.
// Use this for validating function results and exit conditions.
func Ensure(condition bool, message string) {
if !condition {
panic(ErrPostconditionViolation.Error() + ": " + message)
}
}