blob: 2d3adde51890a9a4ed962297f5199f25f2e2c25d [file] [log] [blame]
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Package errs defines common err messages emitted by this interpreter. This is mostly
// useful for testing when we need to distinguish a starlark language error from an error
// in client code.
package errs
import (
"fmt"
)
// Reason is an error prefix describing the reason for an interpreter error.
type Reason string
var (
// ErrInvalidArg signifies that an invalid argument was provided.
ErrInvalidArg Reason = "[fxicfg] invalid argument"
// ErrIllegalWrite signifies that a write-operation is not allowed.
ErrIllegalWrite Reason = "[fxicfg] cannot write value"
)
// WithReason returns a new error annotated with the given reason and message.
func WithReason(reason Reason, format string, args ...interface{}) error {
return fmt.Errorf("%s: %s", reason, fmt.Sprintf(format, args...))
}