|
5 | 5 | "context"
|
6 | 6 | "encoding/json"
|
7 | 7 | "errors"
|
| 8 | + "fmt" |
8 | 9 | "os"
|
9 | 10 | "runtime"
|
10 | 11 | "time"
|
@@ -70,47 +71,47 @@ func InfoWithContext(ctx context.Context) (*InfoStat, error) {
|
70 | 71 |
|
71 | 72 | ret.Hostname, err = os.Hostname()
|
72 | 73 | if err != nil && !errors.Is(err, common.ErrNotImplementedError) {
|
73 |
| - return nil, err |
| 74 | + return nil, fmt.Errorf("getting hostname: %w", err) |
74 | 75 | }
|
75 | 76 |
|
76 | 77 | ret.Platform, ret.PlatformFamily, ret.PlatformVersion, err = PlatformInformationWithContext(ctx)
|
77 | 78 | if err != nil && !errors.Is(err, common.ErrNotImplementedError) {
|
78 |
| - return nil, err |
| 79 | + return nil, fmt.Errorf("getting platform information: %w", err) |
79 | 80 | }
|
80 | 81 |
|
81 | 82 | ret.KernelVersion, err = KernelVersionWithContext(ctx)
|
82 | 83 | if err != nil && !errors.Is(err, common.ErrNotImplementedError) {
|
83 |
| - return nil, err |
| 84 | + return nil, fmt.Errorf("getting kernel version: %w", err) |
84 | 85 | }
|
85 | 86 |
|
86 | 87 | ret.KernelArch, err = KernelArch()
|
87 | 88 | if err != nil && !errors.Is(err, common.ErrNotImplementedError) {
|
88 |
| - return nil, err |
| 89 | + return nil, fmt.Errorf("getting kernel archictecture: %w", err) |
89 | 90 | }
|
90 | 91 |
|
91 | 92 | ret.VirtualizationSystem, ret.VirtualizationRole, err = VirtualizationWithContext(ctx)
|
92 | 93 | if err != nil && !errors.Is(err, common.ErrNotImplementedError) {
|
93 |
| - return nil, err |
| 94 | + return nil, fmt.Errorf("getting virtualization information: %w", err) |
94 | 95 | }
|
95 | 96 |
|
96 | 97 | ret.BootTime, err = BootTimeWithContext(ctx)
|
97 | 98 | if err != nil && !errors.Is(err, common.ErrNotImplementedError) {
|
98 |
| - return nil, err |
| 99 | + return nil, fmt.Errorf("getting boot time: %w", err) |
99 | 100 | }
|
100 | 101 |
|
101 | 102 | ret.Uptime, err = UptimeWithContext(ctx)
|
102 | 103 | if err != nil && !errors.Is(err, common.ErrNotImplementedError) {
|
103 |
| - return nil, err |
| 104 | + return nil, fmt.Errorf("getting uptime: %w", err) |
104 | 105 | }
|
105 | 106 |
|
106 | 107 | ret.Procs, err = numProcs(ctx)
|
107 | 108 | if err != nil && !errors.Is(err, common.ErrNotImplementedError) {
|
108 |
| - return nil, err |
| 109 | + return nil, fmt.Errorf("getting number of procs: %w", err) |
109 | 110 | }
|
110 | 111 |
|
111 | 112 | ret.HostID, err = HostIDWithContext(ctx)
|
112 | 113 | if err != nil && !errors.Is(err, common.ErrNotImplementedError) {
|
113 |
| - return nil, err |
| 114 | + return nil, fmt.Errorf("getting host ID: %w", err) |
114 | 115 | }
|
115 | 116 |
|
116 | 117 | return ret, nil
|
|
0 commit comments