2017-06-26 23:46:34 +02:00
|
|
|
// Copyright 2016-2017, Pulumi Corporation. All rights reserved.
|
2017-01-26 02:58:16 +01:00
|
|
|
|
|
|
|
package errors
|
|
|
|
|
|
|
|
import (
|
2017-09-22 04:18:21 +02:00
|
|
|
"github.com/pulumi/pulumi/pkg/diag"
|
|
|
|
"github.com/pulumi/pulumi/pkg/util/contract"
|
2017-01-26 02:58:16 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
// errors tracks all existing errors, keyed by their unique ID.
|
|
|
|
var errors = make(map[diag.ID]*diag.Diag)
|
|
|
|
|
|
|
|
// newError registers a new error message underneath the given unique ID.
|
|
|
|
func newError(id diag.ID, message string) *diag.Diag {
|
|
|
|
contract.Assert(errors[id] == nil)
|
|
|
|
e := &diag.Diag{ID: id, Message: message}
|
|
|
|
errors[id] = e
|
|
|
|
return e
|
|
|
|
}
|
|
|
|
|
|
|
|
// newWarning registers a new warning message underneath the given unique ID.
|
|
|
|
func newWarning(id diag.ID, message string) *diag.Diag {
|
|
|
|
// At the moment, there isn't a distinction between errors and warnings; however, we use different functions just in
|
|
|
|
// case someday down the road there is, and so we don't have to go audit all callsites.
|
|
|
|
return newError(id, message)
|
|
|
|
}
|