mirror of
https://github.com/ent/ent.git
synced 2026-05-22 09:31:45 +03:00
entc: adding fail method to template engine
Signed-off-by: Alex Snast <alexsn@fb.com>
This commit is contained in:
@@ -6,6 +6,7 @@ package gen
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
@@ -63,6 +64,7 @@ var (
|
||||
"unset": unset,
|
||||
"hasKey": hasKey,
|
||||
"list": list,
|
||||
"fail": fail,
|
||||
}
|
||||
rules = ruleset()
|
||||
acronyms = make(map[string]struct{})
|
||||
@@ -431,3 +433,8 @@ func hasKey(d map[string]interface{}, key string) bool {
|
||||
func list(v ...interface{}) []interface{} {
|
||||
return v
|
||||
}
|
||||
|
||||
// fail unconditionally returns an empty string and an error with the specified text.
|
||||
func fail(msg string) (string, error) {
|
||||
return "", errors.New(msg)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user