Skip to content

Commit

Permalink
Improve some error messages (#433)
Browse files Browse the repository at this point in the history
* Improve some error messages

* comment

* missed one
  • Loading branch information
phliar authored Mar 30, 2020
1 parent b44ff93 commit a0b5e96
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 89 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Changelog

## v3.4.21 (unreleased)
- Nothing changed yet
## v3.4.22 (unreleased)
- no changes yet,

## v3.4.21 (2020-03-30)
- First pass to fix the terrible error messages in the client.

## v3.4.20 (2020-03-12)
- Added String() methods to entity structs
Expand Down
14 changes: 7 additions & 7 deletions entity_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,7 @@ func parseIndexTag(indexName, dosaAnnotation string) (string, *PrimaryKey, []str
// index name struct must be exported in the entity,
// otherwise it will be ignored when upserting the schema.
if len(indexName) != 0 && unicode.IsLower([]rune(indexName)[0]) {
expected := []rune(indexName)
expected[0] = unicode.ToUpper(expected[0])
return "", nil, nil, fmt.Errorf("index name (%s) must be exported, "+
"try (%s) instead", indexName, string(expected))
return "", nil, nil, fmt.Errorf("index %q is not exported", indexName)
}
tag := dosaAnnotation

Expand All @@ -306,7 +303,8 @@ func parseIndexTag(indexName, dosaAnnotation string) (string, *PrimaryKey, []str
//find the name
fullNameTag, name, err := parseNameTag(tag, indexName)
if err != nil {
return "", nil, nil, errors.Wrapf(err, "invalid name tag: %s", tag)
// parseNameTag returns a sane error.
return "", nil, nil, err
}
tag = strings.Replace(tag, fullNameTag, "", 1)

Expand Down Expand Up @@ -447,7 +445,8 @@ func parseEntityTag(structName, dosaAnnotation string) (string, time.Duration, E
// find the name
fullNameTag, name, err := parseNameTag(tag, structName)
if err != nil {
return "", NoTTL(), EtlOff, nil, errors.Wrapf(err, "invalid name tag: %s", tag)
// parseNameTag returns a sane error.
return "", NoTTL(), EtlOff, nil, err
}
tag = strings.Replace(tag, fullNameTag, "", 1)

Expand Down Expand Up @@ -486,7 +485,8 @@ func parseField(typ Type, isPointer bool, name string, tag string) (*ColumnDefin
// parse name tag
fullNameTag, name, err := parseNameTag(tag, name)
if err != nil {
return nil, fmt.Errorf("invalid name tag: %s", tag)
// parseNameTag returns a sane error.
return nil, err
}

tag = strings.Replace(tag, fullNameTag, "", 1)
Expand Down
Loading

0 comments on commit a0b5e96

Please sign in to comment.