forked from free-lancers/electricity_bill_calc_service
feat(report):已完成用户抄表记录的上传处理。
This commit is contained in:
34
exceptions/batch_error.go
Normal file
34
exceptions/batch_error.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package exceptions
|
||||
|
||||
import (
|
||||
"electricity_bill_calc/excel"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type BatchError struct {
|
||||
Errs []error
|
||||
}
|
||||
|
||||
func NewBatchError() *BatchError {
|
||||
return &BatchError{Errs: make([]error, 0)}
|
||||
}
|
||||
|
||||
func (e *BatchError) AddError(errs ...error) {
|
||||
e.Errs = append(e.Errs, errs...)
|
||||
}
|
||||
|
||||
func (e BatchError) Len() int {
|
||||
return len(e.Errs)
|
||||
}
|
||||
|
||||
func NewBatchExcelAnalysisError(errs []excel.ExcelAnalysisError) *BatchError {
|
||||
be := &BatchError{Errs: make([]error, 0)}
|
||||
for _, e := range errs {
|
||||
be.Errs = append(be.Errs, e)
|
||||
}
|
||||
return be
|
||||
}
|
||||
|
||||
func (e BatchError) Error() string {
|
||||
return fmt.Sprintf("存在批量错误,共 %d 个", len(e.Errs))
|
||||
}
|
Reference in New Issue
Block a user