internal/openapi/generator/data/errors.go   A
last analyzed

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 50%

Importance

Changes 0
Metric Value
cc 3
eloc 16
dl 0
loc 27
ccs 2
cts 4
cp 0.5
crap 4.125
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A data.*ErrGenerationFailed.Error 0 6 2
A data.*ErrGenerationFailed.Unwrap 0 2 1
1
package data
2
3
import (
4
	"errors"
5
	"fmt"
6
)
7
8
type ErrGenerationFailed struct {
9
	GeneratorID string
10
	Message     string
11
	Path        string
12
	Previous    error
13
}
14
15
func (err *ErrGenerationFailed) Error() string {
16 1
	if err.Previous == nil {
17 1
		return fmt.Sprintf("[%s] %s", err.GeneratorID, err.Message)
18
	}
19
20
	return fmt.Sprintf("[%s] %s: %s", err.GeneratorID, err.Message, err.Previous.Error())
21
}
22
23
func (err *ErrGenerationFailed) Unwrap() error {
24
	return err.Previous
25
}
26
27
var errAttemptsLimitExceeded = errors.New("attempts limit exceeded")
28