Skip to content

Commit

Permalink
Merge pull request #27 from goark/debug-and-refactoring
Browse files Browse the repository at this point in the history
Fixed *.Decode method when not enough metrics (issue ##26)
  • Loading branch information
spiegel-im-spiegel authored Jan 31, 2023
2 parents cb90764 + 4759b6c commit 290d6f8
Show file tree
Hide file tree
Showing 16 changed files with 181 additions and 1,198 deletions.
42 changes: 11 additions & 31 deletions cvsserr/errors.go
Original file line number Diff line number Diff line change
@@ -1,39 +1,19 @@
package cvsserr

import "fmt"
import "errors"

// Num is error number for CVSS
type Num int

const (
ErrNullPointer Num = iota + 1
ErrUndefinedMetric
ErrInvalidVector
ErrNotSupportVer
ErrNotSupportMetric
ErrInvalidTemplate
ErrSameMetric
ErrInvalidValue
var (
ErrNullPointer = errors.New("Null reference instance")
ErrUndefinedMetric = errors.New("undefined metric")
ErrInvalidVector = errors.New("invalid vector")
ErrNotSupportVer = errors.New("not support version")
ErrNotSupportMetric = errors.New("not support metric")
ErrInvalidTemplate = errors.New("invalid templete string")
ErrSameMetric = errors.New("exist same metric")
ErrInvalidValue = errors.New("invalid value of metric")
ErrNoMetrics = errors.New("no metrics")
)

var errMessage = map[Num]string{
ErrNullPointer: "Null reference instance",
ErrUndefinedMetric: "undefined metric",
ErrInvalidVector: "invalid vector",
ErrNotSupportVer: "not support version",
ErrNotSupportMetric: "not support metric",
ErrInvalidTemplate: "invalid templete string",
ErrSameMetric: "exist same metric",
ErrInvalidValue: "invalid value of metric",
}

func (n Num) Error() string {
if s, ok := errMessage[n]; ok {
return s
}
return fmt.Sprintf("unknown error (%d)", int(n))
}

/* Copyright 2018-2023 Spiegel
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
46 changes: 0 additions & 46 deletions cvsserr/errors_test.go

This file was deleted.

57 changes: 0 additions & 57 deletions v2/base/base.go

This file was deleted.

Loading

0 comments on commit 290d6f8

Please sign in to comment.