Files
napi-go/napi_status.go
Matheus Sampaio Queiroga 32f3ff500d Update pkg to same Node addon Header (#8)
Reviewed-on: #8
Co-authored-by: Matheus Sampaio Queiroga <srherobrine20@gmail.com>
Co-committed-by: Matheus Sampaio Queiroga <srherobrine20@gmail.com>
2025-04-27 06:59:21 +00:00

36 lines
961 B
Go

package napi
import "sirherobrine23.com.br/Sirherobrine23/napi-go/internal/napi"
// Process status to return error if StatusOK return nil on error
func mustValueErr[T any](input T, status napi.Status) (T, error) {
if status != napi.StatusOK {
return input, napi.StatusError(status)
}
return input, nil
}
// return error from status
func singleMustValueErr(status napi.Status) error {
if status != napi.StatusOK {
return napi.StatusError(status)
}
return nil
}
// Process status to return error if StatusOK return nil on error
func mustValueErr2[T any](input T, _ bool, status napi.Status) (T, error) {
if status != napi.StatusOK {
return input, napi.StatusError(status)
}
return input, nil
}
// Process status to return error if StatusOK return nil on error
func mustValueErr3[T, C any](input T, i2 C, status napi.Status) (T, C, error) {
if status != napi.StatusOK {
return input, i2, napi.StatusError(status)
}
return input, i2, nil
}