@@ -153,25 +153,23 @@ std::string IPC::getSocket1Reply(const std::string& rq) {
153153 const auto serverSocket = socket (AF_UNIX, SOCK_STREAM, 0 );
154154
155155 if (serverSocket < 0 ) {
156- spdlog::error (" Hyprland IPC: Couldn't open a socket (1)" );
157- return " " ;
156+ throw std::runtime_error (" Hyprland IPC: Couldn't open a socket (1)" );
158157 }
159158
160159 memset (&aiHints, 0 , sizeof (struct addrinfo ));
161160 aiHints.ai_family = AF_UNSPEC;
162161 aiHints.ai_socktype = SOCK_STREAM;
163162
164163 if (getaddrinfo (" localhost" , nullptr , &aiHints, &aiRes) != 0 ) {
165- spdlog::error (" Hyprland IPC: Couldn't get host (2)" );
166- return " " ;
164+ throw std::runtime_error (" Hyprland IPC: Couldn't get host (2)" );
167165 }
168166
169167 // get the instance signature
170168 auto * instanceSig = getenv (" HYPRLAND_INSTANCE_SIGNATURE" );
171169
172170 if (instanceSig == nullptr ) {
173- spdlog::error ( " Hyprland IPC: HYPRLAND_INSTANCE_SIGNATURE was not set! (Is Hyprland running?) " );
174- return " " ;
171+ throw std::runtime_error (
172+ " Hyprland IPC: HYPRLAND_INSTANCE_SIGNATURE was not set! (Is Hyprland running?) " ) ;
175173 }
176174
177175 sockaddr_un serverAddress = {0 };
@@ -182,14 +180,12 @@ std::string IPC::getSocket1Reply(const std::string& rq) {
182180 // Use snprintf to copy the socketPath string into serverAddress.sun_path
183181 if (snprintf (serverAddress.sun_path , sizeof (serverAddress.sun_path ), " %s" , socketPath.c_str ()) <
184182 0 ) {
185- spdlog::error (" Hyprland IPC: Couldn't copy socket path (6)" );
186- return " " ;
183+ throw std::runtime_error (" Hyprland IPC: Couldn't copy socket path (6)" );
187184 }
188185
189186 if (connect (serverSocket, reinterpret_cast <sockaddr*>(&serverAddress), sizeof (serverAddress)) <
190187 0 ) {
191- spdlog::error (" Hyprland IPC: Couldn't connect to " + socketPath + " . (3)" );
192- return " " ;
188+ throw std::runtime_error (" Hyprland IPC: Couldn't connect to " + socketPath + " . (3)" );
193189 }
194190
195191 auto sizeWritten = write (serverSocket, rq.c_str (), rq.length ());
0 commit comments