2323#include " ../../ControlLib/CpuTelemetryInfo.h"
2424#include " ../../PresentMonService/GlobalIdentifiers.h"
2525#include " FrameEventQuery.h"
26-
26+ # include " Exception.h "
2727
2828#define GLOG_NO_ABBREVIATED_SEVERITIES
2929#include < glog/logging.h>
@@ -58,12 +58,12 @@ namespace pmon::mid
5858
5959 // Exit if an error other than ERROR_PIPE_BUSY occurs.
6060 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 };
6262 }
6363
6464 // All pipe instances are busy, so wait for 20 seconds.
6565 if (!WaitNamedPipeA (pipeName, 20000 )) {
66- throw std::runtime_error{ " Pipe sessions full " };
66+ throw pmon::mid::Exception{ (PM_STATUS) 23 };
6767 }
6868 }
6969 // The pipe connected; change to message-read mode.
@@ -73,26 +73,33 @@ namespace pmon::mid
7373 NULL ,
7474 NULL );
7575 if (!success) {
76- throw std::runtime_error{ " Pipe error " };
76+ throw pmon::mid::Exception{ (PM_STATUS) 24 };
7777 }
7878 pNamedPipeHandle.reset (namedPipeHandle);
7979 clientProcessId = GetCurrentProcessId ();
8080 // connect to the introspection nsm
8181 pComms = ipc::MakeMiddlewareComms (std::move (introNsmOverride));
8282
8383 // 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)
9190 {
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+ }
9496 }
9597 }
98+ catch (...)
99+ {
100+ throw pmon::mid::Exception{ (PM_STATUS)25 };
101+ }
102+
96103 // Update the static GPU metric data from the service
97104 GetStaticGpuMetrics ();
98105 GetStaticCpuMetrics ();
0 commit comments