package network

import (
	"isle/daemon/daecommon"
	"isle/daemon/jsonrpc2"
)

const (
	errCodeInitializing = daecommon.ErrorCodeRangeNetwork + iota
	errCodeInvalidConfig
	errCodeHostNotFound
	errCodeIPInUse
	errCodeSecretNotFound
)

var (
	// ErrInitializing is returned when a network is unavailable due to still
	// being initialized.
	ErrInitializing = jsonrpc2.NewError(errCodeInitializing, "Network is being initialized")

	// ErrInvalidConfig is returned when the daemon's configuration is invalid
	// for an operation being attempted.
	//
	// The Data field will be a string containing further details.
	ErrInvalidConfig = jsonrpc2.NewError(errCodeInvalidConfig, "Invalid daemon config")

	// ErrHostNotFound is returned when performing an operation which expected a
	// host to exist in the network, but that host wasn't found.
	ErrHostNotFound = jsonrpc2.NewError(errCodeHostNotFound, "Host not found")

	// ErrIPInUse is returned when performing an operation which was provided an
	// IP already in use by another host in the network.
	ErrIPInUse = jsonrpc2.NewError(errCodeIPInUse, "IP in use")

	// ErrSecretNotFound is returned when a secret was required to perform some
	// action, but the secret is not found in the secret store.
	ErrSecretNotFound = jsonrpc2.NewError(errCodeSecretNotFound, "Secret not found")
)