Skip to content

Commit 6d744e3

Browse files
committed
ref: errors
1 parent 20c509a commit 6d744e3

File tree

11 files changed

+53
-53
lines changed

11 files changed

+53
-53
lines changed

bik/bik.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ import (
1010
// example valid format is 044525225
1111
func Validate(bik string) (bool, error) {
1212
if len(bik) != 9 {
13-
pkg, err := ru_doc_code.GetPackageName()
13+
name, err := ru_doc_code.GetModuleName()
1414
if err != nil {
1515
return false, err
1616
}
1717
return false, &ru_doc_code.CommonError{
18-
Method: pkg,
18+
Method: name,
1919
Err: ru_doc_code.ErrInvalidLength,
2020
}
2121
}

errors.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,23 @@ var (
1212
// ErrInvalidLength invalid input document code length
1313
ErrInvalidLength = errors.New("invalid length")
1414

15-
// ErrInvalidFormattedSNILSLength
15+
// ErrInvalidFormattedSNILSLength invalid formatted length of snils
1616
ErrInvalidFormattedSNILSLength = errors.New("invalid formatted snils length")
1717

18-
// ErrRegistrationReasonCode
18+
// ErrRegistrationReasonCode invalid registration reason code
1919
ErrRegistrationReasonCode = errors.New("invalid registration reason code")
2020

21-
// ErrInvalidValue
21+
// ErrInvalidValue invalid input value
2222
ErrInvalidValue = errors.New("invalid code value")
2323

24-
// ErrInvalidBIKCountryCode
24+
// ErrInvalidBIKCountryCode invalid bik code country
2525
ErrInvalidBIKCountryCode = errors.New("invalid bik country code")
2626

27-
// ErrNotImplemented
27+
// ErrNotImplemented not implemented method error
2828
ErrNotImplemented = errors.New("method does not implemented")
2929
)
3030

31+
// CommonError common error wrapped base error
3132
type CommonError struct {
3233
Method string
3334
Err error
@@ -37,7 +38,8 @@ func (c *CommonError) Error() string {
3738
return fmt.Sprintf("%s: %s", c.Method, c.Err.Error())
3839
}
3940

40-
func GetPackageName() (string, error) {
41+
// GetModuleName get package name in runtime
42+
func GetModuleName() (string, error) {
4143
pc, _, _, ok := runtime.Caller(1)
4244
if !ok {
4345
return "", errors.New("invalid runtime caller")

inn/inn.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ type INN struct {
2424
// example: input format is 7707083893
2525
func Validate(inn string) (bool, error) {
2626
if len(inn) != lengthLegal && len(inn) != lengthPhysical {
27-
pkg, err := ru_doc_code.GetPackageName()
27+
name, err := ru_doc_code.GetModuleName()
2828
if err != nil {
2929
return false, err
3030
}
3131
return false, &ru_doc_code.CommonError{
32-
Method: pkg,
32+
Method: name,
3333
Err: ru_doc_code.ErrInvalidLength,
3434
}
3535
}

kpp/kpp.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package kpp
22

3-
import (
4-
ru_doc_code "github.com/mrfoe7/ru-doc-code"
5-
)
3+
import ru_doc_code "github.com/mrfoe7/ru-doc-code"
64

75
type KPP struct {
86
Code ru_doc_code.TaxRegionCode
@@ -14,12 +12,12 @@ type KPP struct {
1412
// example: input format is 773643301
1513
func Validate(kpp string) (bool, error) {
1614
if len(kpp) != 9 {
17-
pkg, err := ru_doc_code.GetPackageName()
15+
name, err := ru_doc_code.GetModuleName()
1816
if err != nil {
1917
return false, err
2018
}
2119
return false, &ru_doc_code.CommonError{
22-
Method: pkg,
20+
Method: name,
2321
Err: ru_doc_code.ErrInvalidLength,
2422
}
2523
}

ogrn/ogrn.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ import (
1010
// example: input format is 1027700132195
1111
func Validate(ogrn string) (bool, error) {
1212
if len(ogrn) != 13 {
13-
pkg, err := ru_doc_code.GetPackageName()
13+
name, err := ru_doc_code.GetModuleName()
1414
if err != nil {
1515
return false, err
1616
}
1717
return false, &ru_doc_code.CommonError{
18-
Method: pkg,
18+
Method: name,
1919
Err: ru_doc_code.ErrInvalidLength,
2020
}
2121
}

ogrnip/ogrnip.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ import (
1010
// example: input format is 304500116000157
1111
func Validate(ogrnip string) (bool, error) {
1212
if len(ogrnip) != 15 {
13-
pkg, err := ru_doc_code.GetPackageName()
13+
name, err := ru_doc_code.GetModuleName()
1414
if err != nil {
1515
return false, err
1616
}
1717
return false, &ru_doc_code.CommonError{
18-
Method: pkg,
18+
Method: name,
1919
Err: ru_doc_code.ErrInvalidLength,
2020
}
2121
}

okato/okato.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
package okato
2-
3-
import ru_doc_code "github.com/mrfoe7/ru-doc-code"
4-
5-
// Validate check to valid OKATO format
6-
// example: input format is 17205000000
7-
func Validate() (bool, error) {
8-
return false, ru_doc_code.ErrNotImplemented
9-
}
1+
package okato
2+
3+
import ru_doc_code "github.com/mrfoe7/ru-doc-code"
4+
5+
// Validate check to valid OKATO format
6+
// example: input format is 17205000000
7+
func Validate() (bool, error) {
8+
return false, ru_doc_code.ErrNotImplemented
9+
}

okato/okato_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
package okato
2-
3-
import "testing"
4-
5-
func TestValidate(t *testing.T) {
6-
7-
}
1+
package okato
2+
3+
import "testing"
4+
5+
func TestValidate(t *testing.T) {
6+
7+
}

oktmo/oktmo.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
package oktmo
2-
3-
import ru_doc_code "github.com/mrfoe7/ru-doc-code"
4-
5-
// Validate check to valid OKTMO format
6-
// example: input format is 17605101
7-
func Validate() (bool, error) {
8-
return false, ru_doc_code.ErrNotImplemented
9-
}
1+
package oktmo
2+
3+
import ru_doc_code "github.com/mrfoe7/ru-doc-code"
4+
5+
// Validate check to valid OKTMO format
6+
// example: input format is 17605101
7+
func Validate() (bool, error) {
8+
return false, ru_doc_code.ErrNotImplemented
9+
}

oktmo/oktmo_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
package oktmo
2-
3-
import "testing"
4-
5-
func TestValidate(t *testing.T) {
6-
7-
}
1+
package oktmo
2+
3+
import "testing"
4+
5+
func TestValidate(t *testing.T) {
6+
7+
}

0 commit comments

Comments
 (0)