--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact: Pawel Kubik <p.kubik@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+/**
+ * @file
+ * @author Pawel Kubik (p.kubik@samsung.com)
+ * @brief Exceptions for the cli
+ */
+
+
+#ifndef CLI_EXCEPTION_HPP
+#define CLI_EXCEPTION_HPP
+
+#include "base-exception.hpp"
+
+
+namespace vasum {
+namespace cli {
+
+
+/**
+ * Base class for exceptions in Vasum CLI
+ */
+struct CliException: public VasumException {
+
+ CliException(const std::string& error) : VasumException(error) {}
+};
+
+struct IOException: public CliException {
+
+ IOException(const std::string& error) : CliException(error) {}
+};
+
+} // namespace cli
+} // namespace vasum
+
+#endif // CLI_EXCEPTION_HPP
#include "command-line-interface.hpp"
#include "vasum-client.h"
#include "utils/c-array.hpp"
+#include "cli-exception.hpp"
#include <map>
#include <stdexcept>
string msg = vsm_get_status_message(CommandLineInterface::client);
vsm_client_free(CommandLineInterface::client);
CommandLineInterface::client = nullptr;
- throw runtime_error(msg);
+ throw IOException(msg);
}
}
*/
#include "command-line-interface.hpp"
+#include "cli-exception.hpp"
#include <cstdlib>
#include <map>
{
try {
CommandLineInterface::connect();
+ } catch (const IOException& ex) {
+ std::cerr << ex.what() << std::endl;
+ std::cout << "Client connection error. Is vasum-server running?" << std::endl;
+ return EXIT_FAILURE;
} catch (const std::runtime_error& ex) {
std::cerr << ex.what() << std::endl;
return EXIT_FAILURE;