1package commands
2
3import (
4	"errors"
5	"fmt"
6
7	"github.com/cloudfoundry/bosh-bootloader/helpers"
8	"github.com/cloudfoundry/bosh-bootloader/storage"
9)
10
11func handleTerraformError(err error, state storage.State, stateStore stateStore) error {
12	errorList := helpers.Errors{}
13	errorList.Add(err)
14
15	setErr := stateStore.Set(state)
16	if setErr != nil {
17		errorList.Add(setErr)
18	}
19
20	return errors.New(errorList.Error())
21}
22
23type ExitSuccessfully struct{}
24
25func (e ExitSuccessfully) Error() string {
26	return "Succeeded, exiting early"
27}
28
29type NoBBLStateError struct {
30	dir string
31}
32
33func NewNoBBLStateError(dir string) NoBBLStateError {
34	return NoBBLStateError{dir: dir}
35}
36
37func (e NoBBLStateError) Error() string {
38	return fmt.Sprintf("bbl-state.json not found in %q, ensure you're running this command in the proper state directory or create a new environment with bbl up", e.dir)
39}
40
41func (e NoBBLStateError) String() string {
42	return e.Error()
43}
44