forked from TrueCloudLab/frostfs-node
[#1403] util: Add details to errors
Make error messages more descriptive when parsing LOCODE from string errors appear. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
aeb9884218
commit
f99a0498da
3 changed files with 25 additions and 7 deletions
|
@ -1,6 +1,8 @@
|
|||
package locodecolumn
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/pkg/util/locode"
|
||||
)
|
||||
|
||||
|
@ -16,8 +18,11 @@ func (lc *LocationCode) Symbols() [locationCodeLen]uint8 {
|
|||
|
||||
// LocationCodeFromString parses a string and returns the location code.
|
||||
func LocationCodeFromString(s string) (*LocationCode, error) {
|
||||
if len(s) != locationCodeLen {
|
||||
return nil, locode.ErrInvalidString
|
||||
if l := len(s); l != locationCodeLen {
|
||||
return nil, fmt.Errorf("incorrect location code length: expect: %d, got: %d",
|
||||
locationCodeLen,
|
||||
l,
|
||||
)
|
||||
}
|
||||
|
||||
for i := range s {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue