Files
moloapp/src/google/errors.h
T
retoorandClaude Sonnet 5.5 837de58136 feat(clients): google cloud voice: generic client, TTS, STT, Gemini audio, live voice page
src/google: GoogleClient over molo::clients (key in x-goog-api-key, never in
URLs), Service base, TextToSpeech, SpeechToText, Generative (replies, audio
in, audio out), Recognizer/Synthesizer seams with cloud, gemini and vertex
backends, VoicePipeline with bounded history. Example: /voice live
conversation page, /voice/{say,hear,turn,reset}, /google/status. Keys load
from env, .env.json.local, .env.json. Paid routes are excluded from locust.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-24 04:05:41 +02:00

46 lines
1.4 KiB
C++

#pragma once
// One error type for every Google call. Carries the HTTP status, Google's
// own status string and a message; never the credential.
#include <stdexcept>
#include <string>
#include "clients/response.h"
namespace molo::google {
class GoogleError : public std::runtime_error {
public:
GoogleError(int http_status, std::string status, const std::string& message,
std::string service = "");
int http_status() const noexcept { return http_status_; }
const std::string& status() const noexcept { return status_; }
const std::string& service() const noexcept { return service_; }
// The message alone, without the "molo::google: STATUS:" prefix of what().
const std::string& message() const noexcept { return message_; }
// Validation failure raised before any network traffic.
static GoogleError invalid(const std::string& message);
private:
int http_status_;
std::string status_;
std::string service_;
std::string message_;
};
// Raised when no credential is configured. HTTP 503, status NOT_CONFIGURED.
class NotConfiguredError : public GoogleError {
public:
explicit NotConfiguredError(const std::string& service);
};
// Maps a non-2xx response (Google's {"error":{code,message,status}} body, or
// anything else) to a GoogleError.
GoogleError error_from_response(const std::string& service,
const clients::ClientResponse& response);
} // namespace molo::google