mirror of
https://github.com/MichaelMure/git-bug.git
synced 2024-12-17 21:31:29 +03:00
feat: wrap ErrMultipleConfigEntry to report duplicate key
References #935.
This commit is contained in:
parent
64c18b15a4
commit
49929c034f
@ -39,7 +39,7 @@ func GetUserIdentityId(repo repository.Repo) (entity.Id, error) {
|
||||
if errors.Is(err, repository.ErrNoConfigEntry) {
|
||||
return entity.UnsetId, ErrNoIdentitySet
|
||||
}
|
||||
if err == repository.ErrMultipleConfigEntry {
|
||||
if errors.Is(err, repository.ErrMultipleConfigEntry) {
|
||||
return entity.UnsetId, ErrMultipleIdentitiesSet
|
||||
}
|
||||
if err != nil {
|
||||
|
@ -96,7 +96,7 @@ func (m *mergedConfig) ReadBool(key string) (bool, error) {
|
||||
if err == nil {
|
||||
return v, nil
|
||||
}
|
||||
if !errors.Is(err, ErrNoConfigEntry) && err != ErrMultipleConfigEntry {
|
||||
if !errors.Is(err, ErrNoConfigEntry) && !errors.Is(err, ErrMultipleConfigEntry) {
|
||||
return false, err
|
||||
}
|
||||
return m.global.ReadBool(key)
|
||||
@ -107,7 +107,7 @@ func (m *mergedConfig) ReadString(key string) (string, error) {
|
||||
if err == nil {
|
||||
return val, nil
|
||||
}
|
||||
if !errors.Is(err, ErrNoConfigEntry) && err != ErrMultipleConfigEntry {
|
||||
if !errors.Is(err, ErrNoConfigEntry) && !errors.Is(err, ErrMultipleConfigEntry) {
|
||||
return "", err
|
||||
}
|
||||
return m.global.ReadString(key)
|
||||
@ -118,7 +118,7 @@ func (m *mergedConfig) ReadTimestamp(key string) (time.Time, error) {
|
||||
if err == nil {
|
||||
return val, nil
|
||||
}
|
||||
if !errors.Is(err, ErrNoConfigEntry) && err != ErrMultipleConfigEntry {
|
||||
if !errors.Is(err, ErrNoConfigEntry) && !errors.Is(err, ErrMultipleConfigEntry) {
|
||||
return time.Time{}, err
|
||||
}
|
||||
return m.global.ReadTimestamp(key)
|
||||
|
@ -130,7 +130,7 @@ func (cr *goGitConfigReader) ReadString(key string) (string, error) {
|
||||
return "", fmt.Errorf("%w: missing key %s", ErrNoConfigEntry, key)
|
||||
}
|
||||
if len(section.OptionAll(optionName)) > 1 {
|
||||
return "", ErrMultipleConfigEntry
|
||||
return "", fmt.Errorf("%w: duplicated key %s", ErrMultipleConfigEntry, key)
|
||||
}
|
||||
return section.Option(optionName), nil
|
||||
default:
|
||||
@ -144,7 +144,7 @@ func (cr *goGitConfigReader) ReadString(key string) (string, error) {
|
||||
return "", fmt.Errorf("%w: missing key %s", ErrNoConfigEntry, key)
|
||||
}
|
||||
if len(subsection.OptionAll(optionName)) > 1 {
|
||||
return "", ErrMultipleConfigEntry
|
||||
return "", fmt.Errorf("%w: duplicated key %s", ErrMultipleConfigEntry, key)
|
||||
}
|
||||
return subsection.Option(optionName), nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user