23
23
#include " ../../ControlLib/CpuTelemetryInfo.h"
24
24
#include " ../../PresentMonService/GlobalIdentifiers.h"
25
25
#include " FrameEventQuery.h"
26
-
26
+ # include " Exception.h "
27
27
28
28
#define GLOG_NO_ABBREVIATED_SEVERITIES
29
29
#include < glog/logging.h>
@@ -58,12 +58,12 @@ namespace pmon::mid
58
58
59
59
// Exit if an error other than ERROR_PIPE_BUSY occurs.
60
60
if (const auto hr = GetLastError (); hr != ERROR_PIPE_BUSY) {
61
- throw std::runtime_error{ " Service not found " };
61
+ throw pmon::mid::Exception{ (PM_STATUS) 22 };
62
62
}
63
63
64
64
// All pipe instances are busy, so wait for 20 seconds.
65
65
if (!WaitNamedPipeA (pipeName, 20000 )) {
66
- throw std::runtime_error{ " Pipe sessions full " };
66
+ throw pmon::mid::Exception{ (PM_STATUS) 23 };
67
67
}
68
68
}
69
69
// The pipe connected; change to message-read mode.
@@ -73,26 +73,33 @@ namespace pmon::mid
73
73
NULL ,
74
74
NULL );
75
75
if (!success) {
76
- throw std::runtime_error{ " Pipe error " };
76
+ throw pmon::mid::Exception{ (PM_STATUS) 24 };
77
77
}
78
78
pNamedPipeHandle.reset (namedPipeHandle);
79
79
clientProcessId = GetCurrentProcessId ();
80
80
// connect to the introspection nsm
81
81
pComms = ipc::MakeMiddlewareComms (std::move (introNsmOverride));
82
82
83
83
// Get the introspection data
84
- auto & ispec = GetIntrospectionRoot ();
85
-
86
- uint32_t gpuAdapterId = 0 ;
87
- auto deviceView = ispec.GetDevices ();
88
- for (auto dev : deviceView)
89
- {
90
- if (dev.GetType () == PM_DEVICE_TYPE_GRAPHICS_ADAPTER)
84
+ try {
85
+ auto & ispec = GetIntrospectionRoot ();
86
+
87
+ uint32_t gpuAdapterId = 0 ;
88
+ auto deviceView = ispec.GetDevices ();
89
+ for (auto dev : deviceView)
91
90
{
92
- cachedGpuInfo.push_back ({ dev.GetVendor (), dev.GetName (), dev.GetId (), gpuAdapterId, 0 ., 0 , 0 });
93
- gpuAdapterId++;
91
+ if (dev.GetType () == PM_DEVICE_TYPE_GRAPHICS_ADAPTER)
92
+ {
93
+ cachedGpuInfo.push_back ({ dev.GetVendor (), dev.GetName (), dev.GetId (), gpuAdapterId, 0 ., 0 , 0 });
94
+ gpuAdapterId++;
95
+ }
94
96
}
95
97
}
98
+ catch (...)
99
+ {
100
+ throw pmon::mid::Exception{ (PM_STATUS)25 };
101
+ }
102
+
96
103
// Update the static GPU metric data from the service
97
104
GetStaticGpuMetrics ();
98
105
GetStaticCpuMetrics ();
0 commit comments