Passed
Pull Request — main (#166)
by Yume
01:53
created

views.NewHTTPResponseVMFromError   A

Complexity

Conditions 1

Size

Total Lines 4
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
package views
2
3
type HTTPResponseVM struct {
4
	Data    interface{} `json:"data"`
5
	Message string      `json:"message"`
6
}
7
8
func NewHTTPResponseVM(message string, data interface{}) HTTPResponseVM {
9
	return HTTPResponseVM{
10
		Message: message,
11
		Data:    data,
12
	}
13
}
14
15
func NewHTTPResponseVMFromError(err error) HTTPResponseVM {
16
	return HTTPResponseVM{
17
		Message: err.Error(),
18
		Data:    nil,
19
	}
20
}
21