]> git.sesse.net Git - casparcg/commitdiff
Throw user_error exception for errors that are caused by users of the system instead...
authorHelge Norberg <helge.norberg@svt.se>
Thu, 19 Nov 2015 15:54:48 +0000 (16:54 +0100)
committerHelge Norberg <helge.norberg@svt.se>
Thu, 19 Nov 2015 15:54:48 +0000 (16:54 +0100)
35 files changed:
common/base64.cpp
common/except.h
common/param.h
common/tweener.cpp
core/consumer/frame_consumer.cpp
core/diagnostics/osd_graph.cpp
core/frame/frame_transform.cpp
core/help/help_repository.cpp
core/producer/cg_proxy.cpp
core/producer/color/color_producer.cpp
core/producer/frame_producer.cpp
core/producer/scene/expression_parser.cpp
core/producer/scene/expression_parser.h
core/producer/scene/scene_producer.cpp
core/producer/text/text_producer.cpp
core/producer/variable.h
core/system_info_provider.cpp
modules/bluefish/consumer/bluefish_consumer.cpp
modules/bluefish/util/blue_velvet.cpp
modules/decklink/consumer/decklink_consumer.cpp
modules/decklink/decklink_api.h
modules/decklink/producer/decklink_producer.cpp
modules/decklink/util/util.h
modules/ffmpeg/consumer/ffmpeg_consumer.cpp
modules/ffmpeg/consumer/streaming_consumer.cpp
modules/ffmpeg/producer/util/util.cpp
modules/image/producer/image_scroll_producer.cpp
modules/newtek/consumer/newtek_ivga_consumer.cpp
modules/oal/consumer/oal_consumer.cpp
modules/reroute/producer/reroute_producer.cpp
protocol/amcp/AMCPCommandQueue.cpp
protocol/amcp/AMCPCommandsImpl.cpp
shell/main.cpp
shell/server.cpp
shell/windows_specific.cpp

index 93b9c66f57432c330800f7db15b37618dae018fc..3b4f1d11fd18fed87e136d74fd84f619eeb10c97 100644 (file)
@@ -85,7 +85,7 @@ std::vector<unsigned char> from_base64(const std::string& data)
                        [] (char c) { return !std::isspace(static_cast<unsigned char>(c)); });
 
        if (length % 4 != 0)
-               CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info(
+               CASPAR_THROW_EXCEPTION(user_error() << msg_info(
                                "The length of a base64 sequence must be a multiple of 4"));
 
        int padding = 0;
index d62b4d8da08e1737d331777a417f7b7733f84607..5a498acbeaa7cdc910c6839b2b4d9281ca6f7b30 100644 (file)
@@ -36,7 +36,7 @@ typedef boost::error_info<struct tag_arg_name_info,           std::string>    arg_name_info_
 typedef boost::error_info<struct tag_arg_value_info,   std::string>    arg_value_info_t;
 typedef boost::error_info<struct tag_msg_info,                 std::string>    msg_info_t;
 typedef boost::error_info<struct tag_call_stack_info,  std::string>    call_stack_info_t;
-typedef boost::error_info<struct tag_msg_info,                 std::string>    error_info_t;
+typedef boost::error_info<struct tag_error_info,               std::string>    error_info_t;
 typedef boost::error_info<struct tag_source_info,              std::string>    source_info_t;
 typedef boost::error_info<struct tag_file_name_info,   std::string>    file_name_info_t;
 
index 5f459cb03342ad958805cd5a5f56f659e75da044..78d23c2071ed13b5423720dccdbd8523bccbe0eb 100644 (file)
@@ -47,7 +47,7 @@ typename std::enable_if<!std::is_convertible<T, std::wstring>::value, typename s
        }
        catch(...)
        {               
-               CASPAR_THROW_EXCEPTION(invalid_argument() << msg_info("Failed to parse param.") << arg_name_info(name) << nested_exception(std::current_exception()));
+               CASPAR_THROW_EXCEPTION(user_error() << msg_info(L"Failed to parse param " + name) << nested_exception(std::current_exception()));
        }
 }
 
@@ -67,7 +67,7 @@ std::wstring get_param(const std::wstring& name, C&& params, const std::wstring&
        }
        catch(...)
        {               
-               CASPAR_THROW_EXCEPTION(invalid_argument() << msg_info("Failed to parse param.") << arg_name_info(name) << nested_exception(std::current_exception()));
+               CASPAR_THROW_EXCEPTION(user_error() << msg_info(L"Failed to parse param " + name) << nested_exception(std::current_exception()));
        }
 }
 
index abfdac533b07a87dd71ef3fc34663f7324c5984a..d714f3e9a6e73fd7317b59d5e00d4a777ca97f95 100644 (file)
@@ -455,7 +455,7 @@ tweener_t get_tweener(std::wstring name)
                
        auto it = get_tweens().find(name);
        if(it == get_tweens().end())
-               CASPAR_THROW_EXCEPTION(invalid_argument() << msg_info("Could not find tween.") << arg_value_info(name));
+               CASPAR_THROW_EXCEPTION(user_error() << msg_info(L"Could not find tween " + name));
        
        auto tween = it->second;
        return [=](double t, double b, double c, double d)
index 7601f2e50992d3ee35a2a8fdd363ec9ec7f58de2..10fccad3e157f4ee1eae8766eae0359dd31b3366 100644 (file)
@@ -281,7 +281,7 @@ spl::shared_ptr<core::frame_consumer> frame_consumer_registry::create_consumer(
                const std::vector<std::wstring>& params, interaction_sink* sink) const
 {
        if(params.empty())
-               CASPAR_THROW_EXCEPTION(invalid_argument() << arg_name_info("params") << arg_value_info(""));
+               CASPAR_THROW_EXCEPTION(invalid_argument() << msg_info("params cannot be empty"));
        
        auto consumer = frame_consumer::empty();
        auto& consumer_factories = impl_->consumer_factories;
@@ -317,7 +317,7 @@ spl::shared_ptr<frame_consumer> frame_consumer_registry::create_consumer(
        auto found = preconfigured_consumer_factories.find(element_name);
 
        if (found == preconfigured_consumer_factories.end())
-               CASPAR_THROW_EXCEPTION(file_not_found()
+               CASPAR_THROW_EXCEPTION(user_error()
                        << msg_info(L"No consumer factory registered for element name " + element_name));
 
        return spl::make_shared<destroy_consumer_proxy>(
index 502a038cb7b29778fe6f6a13accadd0acab0e1b1..f0606f7e69dc544277c4e2353b8278d282625a36 100644 (file)
@@ -74,7 +74,7 @@ sf::Font& get_default_font()
        {
                sf::Font font;
                if (!font.loadFromFile("LiberationSans-Regular.ttf"))
-                       CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info("LiberationSans-Regular.ttf not found"));
+                       CASPAR_THROW_EXCEPTION(file_not_found() << msg_info("LiberationSans-Regular.ttf not found"));
                return font;
        }();
 
index c5e70239465470a79ad4a74230da51b683acba36..4ba1899202eea6d4daca30d18753c03145785d6f 100644 (file)
@@ -306,7 +306,7 @@ core::chroma::type get_chroma_mode(const std::wstring& str)
        else if (boost::iequals(str, L"blue"))
                return core::chroma::type::blue;
        else
-               CASPAR_THROW_EXCEPTION(invalid_argument() << msg_info("chroma mode has to be one of none, green or blue"));
+               CASPAR_THROW_EXCEPTION(user_error() << msg_info("chroma mode has to be one of none, green or blue"));
 }
 
 std::wstring get_chroma_mode(core::chroma::type type)
index 5b36f580af3426514f0255602caf259d6a93c64e..a4a0921448b81fbde0c8199eb3c3bc10156c0239 100644 (file)
@@ -76,7 +76,7 @@ void help_repository::help(std::set<std::wstring> tags, std::wstring name, help_
        });
 
        if (found.empty())
-               CASPAR_THROW_EXCEPTION(file_not_found() << msg_info(L"Could not find help item " + name));
+               CASPAR_THROW_EXCEPTION(user_error() << msg_info(L"Could not find help item " + name));
 
        for (auto& item : found)
        {
index be5bf421f2e8e002be59cc9df5ce0e794e84d7b0..74a1318e83112232f24990856b8773a04755e3cd 100644 (file)
@@ -187,7 +187,7 @@ public:
                                return rec.second.info_extractor(*found);
                }
 
-               CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info(L"No meta info extractor for " + filename));
+               CASPAR_THROW_EXCEPTION(user_error() << msg_info(L"No meta info extractor for " + filename));
        }
 
        bool is_cg_extension(const std::wstring& extension) const
index dd82ec1980c80792e2c4a5eca059942c39bb203f..88882372793287bfda52588e393a91a02efd1577 100644 (file)
@@ -189,7 +189,7 @@ draw_frame create_color_frame(void* tag, const spl::shared_ptr<frame_factory>& f
 {
        uint32_t value = 0;
        if(!try_get_color(str, value))
-               CASPAR_THROW_EXCEPTION(invalid_argument() << arg_name_info("color") << arg_value_info(str) << msg_info("Invalid color."));
+               CASPAR_THROW_EXCEPTION(user_error() << msg_info(L"Invalid color: " + str));
        
        return create_color_frame(tag, frame_factory, value);
 }
index 948f1f81e9a4ec284309e823aca51b58c5a6d9ab..fa458be4450e2408fbfcdf149f1712383ce936fd 100644 (file)
@@ -173,7 +173,7 @@ uint32_t frame_producer_base::frame_number() const
 
 variable& frame_producer_base::get_variable(const std::wstring& name)
 {
-       CASPAR_THROW_EXCEPTION(caspar_exception() 
+       CASPAR_THROW_EXCEPTION(user_error()
                        << msg_info(L"No variable called " + name + L" found in " + print()));
 }
 
@@ -197,8 +197,8 @@ const spl::shared_ptr<frame_producer>& frame_producer::empty()
                monitor::subject& monitor_output() override {static monitor::subject monitor_subject(""); return monitor_subject;}                                                                              
                std::wstring name() const override {return L"empty";}
                uint32_t frame_number() const override {return 0;}
-               std::future<std::wstring> call(const std::vector<std::wstring>& params) override{CASPAR_THROW_EXCEPTION(not_supported());}
-               variable& get_variable(const std::wstring& name) override { CASPAR_THROW_EXCEPTION(not_supported()); }
+               std::future<std::wstring> call(const std::vector<std::wstring>& params) override{CASPAR_THROW_EXCEPTION(not_implemented());}
+               variable& get_variable(const std::wstring& name) override { CASPAR_THROW_EXCEPTION(not_implemented()); }
                const std::vector<std::wstring>& get_variables() const override { static std::vector<std::wstring> empty; return empty; }
                draw_frame last_frame() {return draw_frame::empty();}
                draw_frame create_thumbnail_frame() {return draw_frame::empty();}
@@ -307,7 +307,7 @@ spl::shared_ptr<core::frame_producer> create_destroy_proxy(spl::shared_ptr<core:
 spl::shared_ptr<core::frame_producer> do_create_producer(const frame_producer_dependencies& dependencies, const std::vector<std::wstring>& params, const std::vector<producer_factory_t>& factories, bool throw_on_fail = false)
 {
        if(params.empty())
-               CASPAR_THROW_EXCEPTION(invalid_argument() << arg_name_info("params") << arg_value_info(""));
+               CASPAR_THROW_EXCEPTION(invalid_argument() << msg_info("params cannot be empty"));
        
        auto producer = frame_producer::empty();
        std::any_of(factories.begin(), factories.end(), [&](const producer_factory_t& factory) -> bool
index 6250a13eb99e14897aefd4ce4024513ecceb9b7f..b4d07cc3c5d7dc81f7710694175df18369e1b71d 100644 (file)
@@ -56,7 +56,7 @@ wchar_t next_non_whitespace(
                }
        }
 
-       CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info(
+       CASPAR_THROW_EXCEPTION(user_error() << msg_info(
                        L"Unexpected end of input (" + error_if_eof + L") in " + str));
 }
 
@@ -80,13 +80,13 @@ boost::any parse_parenthesis(
                const variable_repository& var_repo)
 {
        if (*cursor++ != L'(')
-               CASPAR_THROW_EXCEPTION(caspar_exception()
+               CASPAR_THROW_EXCEPTION(user_error()
                                << msg_info(L"Expected (" + at_position(cursor, str)));
 
        auto expr = parse_expression(cursor, str, var_repo);
 
        if (*cursor++ != L')')
-               CASPAR_THROW_EXCEPTION(caspar_exception()
+               CASPAR_THROW_EXCEPTION(user_error()
                                << msg_info(L"Expected )" + at_position(cursor, str)));
 
        return expr;
@@ -118,7 +118,7 @@ std::wstring parse_string_literal(
        std::wstring literal;
 
        if (*cursor++ != L'"')
-               CASPAR_THROW_EXCEPTION(caspar_exception()
+               CASPAR_THROW_EXCEPTION(user_error()
                                << msg_info(L"Expected (" + at_position(cursor, str)));
 
        bool escaping = false;
@@ -166,7 +166,7 @@ std::wstring parse_string_literal(
                ++cursor;
        }
 
-       CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info(
+       CASPAR_THROW_EXCEPTION(user_error() << msg_info(
                        L"Unexpected end of input (Expected closing \") in " + str));
 }
 
@@ -208,7 +208,7 @@ boost::any parse_variable(
        else if (var.is<bool>())
                return var.as<bool>();
 
-       CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info(
+       CASPAR_THROW_EXCEPTION(user_error() << msg_info(
                                L"Unhandled variable type of " + variable_name
                                + at_position(cursor, str)));
 }
@@ -262,7 +262,7 @@ op parse_operator(std::wstring::const_iterator& cursor, const std::wstring& str)
                        return op(ch, 15, op::op_type::TERNARY);
                case L'-':
                        if (first == L'-')
-                               CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info(
+                               CASPAR_THROW_EXCEPTION(user_error() << msg_info(
                                                L"Did not expect -" + at_position(cursor, str)));
                        else
                                first = ch;
@@ -271,7 +271,7 @@ op parse_operator(std::wstring::const_iterator& cursor, const std::wstring& str)
                        break;
                case L'!':
                        if (first == L'!')
-                               CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info(
+                               CASPAR_THROW_EXCEPTION(user_error() << msg_info(
                                                L"Did not expect !" + at_position(cursor, str)));
                        else
                                first = ch;
@@ -280,7 +280,7 @@ op parse_operator(std::wstring::const_iterator& cursor, const std::wstring& str)
                        break;
                case L'<':
                        if (first == L'<')
-                               CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info(
+                               CASPAR_THROW_EXCEPTION(user_error() << msg_info(
                                                L"Did not expect <" + at_position(cursor, str)));
                        else
                                first = ch;
@@ -289,7 +289,7 @@ op parse_operator(std::wstring::const_iterator& cursor, const std::wstring& str)
                        break;
                case L'>':
                        if (first == L'>')
-                               CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info(
+                               CASPAR_THROW_EXCEPTION(user_error() << msg_info(
                                                L"Did not expect >" + at_position(cursor, str)));
                        else
                                first = ch;
@@ -323,7 +323,7 @@ op parse_operator(std::wstring::const_iterator& cursor, const std::wstring& str)
                                first = L'=';
                        }
                        else
-                               CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info(
+                               CASPAR_THROW_EXCEPTION(user_error() << msg_info(
                                                L"Did not expect =" + at_position(cursor, str)));
 
                        break;
@@ -339,7 +339,7 @@ op parse_operator(std::wstring::const_iterator& cursor, const std::wstring& str)
                                first = L'|';
                        }
                        else
-                               CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info(
+                               CASPAR_THROW_EXCEPTION(user_error() << msg_info(
                                                L"Did not expect =" + at_position(cursor, str)));
 
                        break;
@@ -355,7 +355,7 @@ op parse_operator(std::wstring::const_iterator& cursor, const std::wstring& str)
                                first = L'&';
                        }
                        else
-                               CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info(
+                               CASPAR_THROW_EXCEPTION(user_error() << msg_info(
                                                L"Did not expect =" + at_position(cursor, str)));
 
                        break;
@@ -375,13 +375,13 @@ op parse_operator(std::wstring::const_iterator& cursor, const std::wstring& str)
                        else if (first == L'!')
                                return op(L'!', 3, op::op_type::UNARY);
                        else
-                               CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info(
+                               CASPAR_THROW_EXCEPTION(user_error() << msg_info(
                                                L"Expected second character of operator"
                                                + at_position(cursor, str)));
                }
        }
 
-       CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info(
+       CASPAR_THROW_EXCEPTION(user_error() << msg_info(
                        L"Unexpected end of input (Expected operator) in " + str));
 }
 
@@ -402,7 +402,7 @@ boost::any as_binding(const boost::any& value)
        else if (is<binding<std::wstring>>(value))
                return as<binding<std::wstring>>(value);
        else
-               CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info(
+               CASPAR_THROW_EXCEPTION(user_error() << msg_info(
                                L"Couldn't detect type of " + u16(value.type().name())));
 }
 
@@ -414,7 +414,7 @@ binding<T> require(const boost::any& value)
        if (is<binding<T>>(b))
                return as<binding<T>>(b);
        else
-               CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info(
+               CASPAR_THROW_EXCEPTION(user_error() << msg_info(
                                L"Required binding of type " + u16(typeid(T).name())
                                + L" but got " + u16(value.type().name())));
 }
@@ -459,7 +459,7 @@ binding<std::wstring> stringify(const boost::any& value)
        else if (is<binding<bool>>(b))
                return as<binding<bool>>(b).as<std::wstring>();
        else
-               CASPAR_THROW_EXCEPTION(caspar_exception()
+               CASPAR_THROW_EXCEPTION(user_error()
                                << msg_info(L"Couldn't stringify " + u16(value.type().name())));
 }
 
@@ -637,7 +637,7 @@ void resolve_operators(int precedence, std::vector<boost::any>& tokens)
                                auto& token_colon_operator = tokens.at(i + 2);
 
                                if (as<op>(token_colon_operator).characters != L":")
-                                       CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info(
+                                       CASPAR_THROW_EXCEPTION(user_error() << msg_info(
                                                        L"Expected : as part of ternary expression"));
 
                                auto& token_false_value = tokens.at(i + 3);
@@ -712,7 +712,7 @@ boost::any parse_expression(
        }
 
        if (tokens.empty())
-               CASPAR_THROW_EXCEPTION(caspar_exception()
+               CASPAR_THROW_EXCEPTION(user_error()
                                << msg_info(L"Expected expression"));
 
        int precedence = 1;
@@ -725,21 +725,4 @@ boost::any parse_expression(
        return as_binding(tokens.at(0));
 }
 
-/*template<>
-binding<std::wstring> parse_expression(
-               const std::wstring& str, const variable_repository& var_repo)
-{
-       auto cursor = str.cbegin();
-       auto expr = parse_expression(cursor, str, var_repo);
-
-       if (is<binding<std::wstring>>(expr))
-               return as<binding<std::wstring>>(expr);
-       else if (is<binding<double>>(expr))
-               return as<binding<double>>(expr).as<std::wstring>();
-       else
-               CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info(
-                               L"parse_expression() Unsupported type "
-                               + u16(expr.type().name())));
-}*/
-
 }}}
index 6e54ee254d475499bb82d05ce609261582c2103c..71f2488cd06e2755d3d325b395c768458cb0a975 100644 (file)
@@ -71,7 +71,7 @@ binding<std::wstring> parse_expression(
        else if (is<binding<double>>(expr))
                return as<binding<double>>(expr).as<std::wstring>();
        else
-               CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info(
+               CASPAR_THROW_EXCEPTION(user_error() << msg_info(
                                L"parse_expression() Unsupported type "
                                + u16(expr.type().name())));
 }
index 78d919343acd72bdc0997dd079882f96ea9aed63..6fc01cc231f0235f627d5c852093ac0246cb1088 100644 (file)
@@ -101,7 +101,7 @@ mark_action get_mark_action(const std::wstring& name)
        else if (name == L"remove")
                return mark_action::remove;
        else
-               CASPAR_THROW_EXCEPTION(invalid_argument() << msg_info(L"Invalid mark_action " + name));
+               CASPAR_THROW_EXCEPTION(user_error() << msg_info(L"Invalid mark_action " + name));
 }
 
 struct marker
@@ -184,7 +184,7 @@ struct scene_producer::impl
                auto found = variables_.find(name);
 
                if (found == variables_.end())
-                       CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info(name + L" not found in scene"));
+                       CASPAR_THROW_EXCEPTION(user_error() << msg_info(name + L" not found in scene"));
 
                return *found->second;
        }
@@ -433,7 +433,7 @@ struct scene_producer::impl
                else if (call == L"next()")
                        next();
                else
-                       CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info(L"Unknown call " + call));
+                       CASPAR_THROW_EXCEPTION(user_error() << msg_info(L"Unknown call " + call));
 
                return L"";
        }
index ff3f2913e3f70142c6bce7dc60360ace1a7cca91..8b1b0a7079a9bae8c69a2fe62fd6f1774645c5ec 100644 (file)
@@ -230,7 +230,7 @@ public:
                else if (name == L"tracking")
                        return tracking_;
 
-               CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info(L"text_producer does not have a variable called " + name));
+               CASPAR_THROW_EXCEPTION(user_error() << msg_info(L"text_producer does not have a variable called " + name));
        }
 
        const std::vector<std::wstring>& get_variables() const
index c8ce6cec5d15ea86692fa38b76d324b8bce918f9..e1a8726540a2d80508d66f6133b60aa707d94326 100644 (file)
@@ -122,7 +122,7 @@ public:
                        else if (raw_value == L"false")
                                bool_binding.set(false);
                        else
-                               CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info(L"bool constants should be true or false"));
+                               CASPAR_THROW_EXCEPTION(user_error() << msg_info(L"bool constants should be true or false"));
                }
                else
                        value_.set(boost::lexical_cast<T>(raw_value));
index 100886a4315c83b77e730452fb2d525b4876337f..f23aa06f5070865c68f594eec6e8834effdb0f5b 100644 (file)
@@ -68,7 +68,7 @@ struct system_info_provider_repository::impl
                auto found = version_providers_.find(boost::algorithm::to_lower_copy(version_name));
 
                if (found == version_providers_.end())
-                       CASPAR_THROW_EXCEPTION(file_not_found() << msg_info(L"No version provider with name " + version_name));
+                       CASPAR_THROW_EXCEPTION(user_error() << msg_info(L"No version provider with name " + version_name));
 
                return found->second();
        }
index 77cc4d852ac251a9f79aa98cc544066b401126ee..17d2f2db8160d85df2e8c79ff8963f6be1cbb592 100644 (file)
@@ -478,7 +478,7 @@ spl::shared_ptr<core::frame_consumer> create_consumer(
                auto found_layout = core::audio_channel_layout_repository::get_default()->get_layout(channel_layout);
 
                if (!found_layout)
-                       CASPAR_THROW_EXCEPTION(file_not_found() << msg_info(L"Channel layout " + channel_layout + L" not found"));
+                       CASPAR_THROW_EXCEPTION(user_error() << msg_info(L"Channel layout " + channel_layout + L" not found"));
 
                layout = *found_layout;
        }
@@ -501,7 +501,7 @@ spl::shared_ptr<core::frame_consumer> create_preconfigured_consumer(
                auto found_layout = core::audio_channel_layout_repository::get_default()->get_layout(*channel_layout);
 
                if (!found_layout)
-                       CASPAR_THROW_EXCEPTION(file_not_found() << msg_info(L"Channel layout " + *channel_layout + L" not found"));
+                       CASPAR_THROW_EXCEPTION(user_error() << msg_info(L"Channel layout " + *channel_layout + L" not found"));
 
                layout = *found_layout;
        }
index 700486e9fa700edd54316ce756a79c6d602f0c7f..e1802c6d53a1108e62306d6c5fd242e99e055fa4 100644 (file)
@@ -185,7 +185,7 @@ EVideoMode get_video_mode(CBlueVelvet4& blue, const core::video_format_desc& for
                        vid_fmt = videoMode;                    
        }
        if(vid_fmt == VID_FMT_INVALID)
-               CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info("video-mode not supported.") << arg_value_info(format_desc.name));
+               CASPAR_THROW_EXCEPTION(not_supported() << msg_info(L"video-mode not supported: " + format_desc.name));
 
        return vid_fmt;
 }
@@ -193,7 +193,7 @@ EVideoMode get_video_mode(CBlueVelvet4& blue, const core::video_format_desc& for
 spl::shared_ptr<CBlueVelvet4> create_blue()
 {
        if(!BlueVelvetFactory4 || !encode_hanc_frame)
-               CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info("Bluefish drivers not found."));
+               CASPAR_THROW_EXCEPTION(not_supported() << msg_info("Bluefish drivers not found."));
 
        return spl::shared_ptr<CBlueVelvet4>(BlueVelvetFactory4(), BlueVelvetDestroy);
 }
index 50b5d2c8c3dffe306b90fbed13890d7b1ca64435..7d5454255ce5f5e5a157f9612363786cb58a066c 100644 (file)
@@ -278,7 +278,7 @@ struct key_video_context : public IDeckLinkVideoOutputCallback, boost::noncopyab
 
                if (FAILED(output_->SetScheduledFrameCompletionCallback(this)))
                        CASPAR_THROW_EXCEPTION(caspar_exception()
-                                       << msg_info(u8(print) + " Failed to set key playback completion callback.")
+                                       << msg_info(print + L" Failed to set key playback completion callback.")
                                        << boost::errinfo_api_function("SetScheduledFrameCompletionCallback"));
        }
 
@@ -286,11 +286,11 @@ struct key_video_context : public IDeckLinkVideoOutputCallback, boost::noncopyab
        void enable_video(BMDDisplayMode display_mode, const Print& print)
        {
                if (FAILED(output_->EnableVideoOutput(display_mode, bmdVideoOutputFlagDefault)))
-                       CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info(u8(print()) + " Could not enable key video output."));
+                       CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info(print() + L" Could not enable key video output."));
 
                if (FAILED(output_->SetScheduledFrameCompletionCallback(this)))
                        CASPAR_THROW_EXCEPTION(caspar_exception()
-                                       << msg_info(u8(print()) + " Failed to set key playback completion callback.")
+                                       << msg_info(print() + L" Failed to set key playback completion callback.")
                                        << boost::errinfo_api_function("SetScheduledFrameCompletionCallback"));
        }
 
@@ -443,10 +443,10 @@ public:
        void enable_audio()
        {
                if(FAILED(output_->EnableAudioOutput(bmdAudioSampleRate48kHz, bmdAudioSampleType32bitInteger, out_channel_layout_.num_channels, bmdAudioOutputStreamTimestamped)))
-                               CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info(u8(print()) + " Could not enable audio output."));
+                               CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info(print() + L" Could not enable audio output."));
                                
                if(FAILED(output_->SetAudioCallback(this)))
-                       CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info(u8(print()) + " Could not set audio callback."));
+                       CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info(print() + L" Could not set audio callback."));
 
                CASPAR_LOG(info) << print() << L" Enabled embedded-audio.";
        }
@@ -454,11 +454,11 @@ public:
        void enable_video(BMDDisplayMode display_mode)
        {
                if(FAILED(output_->EnableVideoOutput(display_mode, bmdVideoOutputFlagDefault))) 
-                       CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info(u8(print()) + " Could not enable fill video output."));
+                       CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info(print() + L" Could not enable fill video output."));
                
                if(FAILED(output_->SetScheduledFrameCompletionCallback(this)))
                        CASPAR_THROW_EXCEPTION(caspar_exception() 
-                                                                       << msg_info(u8(print()) + " Failed to set fill playback completion callback.")
+                                                                       << msg_info(print() + L" Failed to set fill playback completion callback.")
                                                                        << boost::errinfo_api_function("SetScheduledFrameCompletionCallback"));
 
                if (key_context_)
@@ -468,10 +468,10 @@ public:
        void start_playback()
        {
                if(FAILED(output_->StartScheduledPlayback(0, format_desc_.time_scale, 1.0))) 
-                       CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info(u8(print()) + " Failed to schedule fill playback."));
+                       CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info(print() + L" Failed to schedule fill playback."));
 
                if (key_context_ && FAILED(key_context_->output_->StartScheduledPlayback(0, format_desc_.time_scale, 1.0)))
-                       CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info(u8(print()) + " Failed to schedule key playback."));
+                       CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info(print() + L" Failed to schedule key playback."));
        }
        
        virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID, LPVOID*)       {return E_NOINTERFACE;}
@@ -628,7 +628,7 @@ public:
                        std::rethrow_exception(exception);              
 
                if(!is_running_)
-                       CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info(u8(print()) + " Is not running."));
+                       CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info(print() + L" Is not running."));
                
                bool audio_ready = !config_.embedded_audio;
                bool video_ready = false;
@@ -835,7 +835,7 @@ spl::shared_ptr<core::frame_consumer> create_consumer(
                auto found_layout = core::audio_channel_layout_repository::get_default()->get_layout(channel_layout);
 
                if (!found_layout)
-                       CASPAR_THROW_EXCEPTION(file_not_found() << msg_info(L"Channel layout " + channel_layout + L" not found."));
+                       CASPAR_THROW_EXCEPTION(user_error() << msg_info(L"Channel layout " + channel_layout + L" not found."));
 
                config.out_channel_layout = *found_layout;
        }
@@ -869,7 +869,7 @@ spl::shared_ptr<core::frame_consumer> create_preconfigured_consumer(
                auto found_layout = core::audio_channel_layout_repository::get_default()->get_layout(*channel_layout);
 
                if (!found_layout)
-                       CASPAR_THROW_EXCEPTION(file_not_found() << msg_info(L"Channel layout " + *channel_layout + L" not found."));
+                       CASPAR_THROW_EXCEPTION(user_error() << msg_info(L"Channel layout " + *channel_layout + L" not found."));
 
                config.out_channel_layout = *found_layout;
        }
index c8d8554d0701d88d7c47d56d97bd512cc0e27781..5d73fbd27d093708a9bbb2859e54535a4687f0aa 100644 (file)
@@ -81,7 +81,7 @@ static com_ptr<IDeckLinkIterator> create_iterator()
 {
     CComPtr<IDeckLinkIterator> pDecklinkIterator;
     if(FAILED(pDecklinkIterator.CoCreateInstance(CLSID_CDeckLinkIterator)))
-        CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info("Decklink drivers not found."));
+        CASPAR_THROW_EXCEPTION(not_supported() << msg_info("Decklink drivers not found."));
     return pDecklinkIterator;
 }
 
@@ -91,7 +91,7 @@ static com_iface_ptr<I> iface_cast(const com_ptr<T>& ptr)
        com_iface_ptr<I> result = ptr;
 
        if (!result)
-               CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info(std::string("Could not cast from ") + typeid(T).name() + " to " + typeid(I).name() + ". This is probably due to old Decklink drivers."));
+               CASPAR_THROW_EXCEPTION(not_supported() << msg_info(std::string("Could not cast from ") + typeid(T).name() + " to " + typeid(I).name() + ". This is probably due to old Decklink drivers."));
 
        return result;
 }
@@ -160,7 +160,7 @@ static com_ptr<IDeckLinkIterator> create_iterator()
     IDeckLinkIterator* iterator = CreateDeckLinkIteratorInstance();
 
     if (iterator == nullptr)
-        CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info("Decklink drivers not found."));
+        CASPAR_THROW_EXCEPTION(not_supported() << msg_info("Decklink drivers not found."));
 
        return wrap_raw<com_ptr>(iterator, true);
 }
index 19521f1f17dbcb72fe0051c949da700e816457cc..d62c27bd5d7aaabbf30c9a6dc91a9acab0c5fada 100644 (file)
@@ -426,7 +426,7 @@ spl::shared_ptr<core::frame_producer> create_producer(const core::frame_producer
                auto found_layout = core::audio_channel_layout_repository::get_default()->get_layout(channel_layout_spec);
 
                if (!found_layout)
-                       CASPAR_THROW_EXCEPTION(file_not_found() << msg_info(L"Channel layout not found."));
+                       CASPAR_THROW_EXCEPTION(user_error() << msg_info(L"Channel layout not found."));
 
                channel_layout = *found_layout;
        }
index 4ffce4b104f0d44a1cf5816582995e39c79b144b..1cfa95f597cf010badf9bf7fa29324f38bb2d6f8 100644 (file)
@@ -132,9 +132,7 @@ BMDDisplayMode get_display_mode(const T& device, BMDDisplayMode format, BMDPixel
        }
 
     if(!m)
-               CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info("Device could not find requested video-format.") 
-                                                                                                << arg_value_info(boost::lexical_cast<std::string>(format))
-                                                                                                << arg_name_info("format"));
+               CASPAR_THROW_EXCEPTION(user_error() << msg_info("Device could not find requested video-format: " + boost::lexical_cast<std::string>(format)));
 
        com_ptr<IDeckLinkDisplayMode> mode = wrap_raw<com_ptr>(m, true);
 
@@ -184,7 +182,7 @@ static com_ptr<IDeckLink> get_device(size_t device_index)
     }
 
        if(n != device_index || !decklink)
-               CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info("Decklink device not found.") << arg_name_info("device_index") << arg_value_info(boost::lexical_cast<std::string>(device_index)));
+               CASPAR_THROW_EXCEPTION(user_error() << msg_info("Decklink device " + boost::lexical_cast<std::string>(device_index) + " not found."));
                
        return decklink;
 }
index 97a1457a9808f438c92997798e7c6f1ac76dfbbd..40a19292470da4975ae8f7b6eec0d30b573981cc 100644 (file)
@@ -209,7 +209,7 @@ struct output_format
                        format = av_guess_format(value.c_str(), nullptr, nullptr);
 
                        if(format == nullptr)
-                               CASPAR_THROW_EXCEPTION(invalid_argument() << arg_name_info("f"));
+                               CASPAR_THROW_EXCEPTION(user_error() << msg_info("Unknown format " + value));
 
                        return true;
                }
@@ -217,7 +217,7 @@ struct output_format
                {
                        auto c = avcodec_find_encoder_by_name(value.c_str());
                        if(c == nullptr)
-                               CASPAR_THROW_EXCEPTION(invalid_argument() << arg_name_info("vcodec"));
+                               CASPAR_THROW_EXCEPTION(user_error() << msg_info("Unknown video codec " + value));
 
                        vcodec = avcodec_find_encoder_by_name(value.c_str())->id;
                        return true;
@@ -227,7 +227,7 @@ struct output_format
                {
                        auto c = avcodec_find_encoder_by_name(value.c_str());
                        if(c == nullptr)
-                               CASPAR_THROW_EXCEPTION(invalid_argument() << arg_name_info("acodec"));
+                               CASPAR_THROW_EXCEPTION(user_error() << msg_info("Unknown audio codec " + value));
 
                        acodec = avcodec_find_encoder_by_name(value.c_str())->id;
 
@@ -236,7 +236,7 @@ struct output_format
                else if(name == "s")
                {
                        if(av_parse_video_size(&width, &height, value.c_str()) < 0)
-                               CASPAR_THROW_EXCEPTION(invalid_argument() << arg_name_info("s"));
+                               CASPAR_THROW_EXCEPTION(user_error() << msg_info("Unknown video size " + value));
                        
                        return true;
                }
index 5184462247d4e79e08708983ae6b23cdeba1c6f8..f8daf9199cbfafdaecc25a0a3fa4118340fd0fb1 100644 (file)
@@ -275,13 +275,13 @@ public:
                                        : avcodec_find_encoder(oc_->oformat->audio_codec);
                        
                        if (!video_codec)
-                               CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info(
+                               CASPAR_THROW_EXCEPTION(user_error() << msg_info(
                                                "Failed to find video codec " + (video_codec_name
                                                                ? *video_codec_name
                                                                : "with id " + boost::lexical_cast<std::string>(
                                                                                oc_->oformat->video_codec))));
                        if (!audio_codec)
-                               CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info(
+                               CASPAR_THROW_EXCEPTION(user_error() << msg_info(
                                                "Failed to find audio codec " + (audio_codec_name
                                                                ? *audio_codec_name
                                                                : "with id " + boost::lexical_cast<std::string>(
index c5fdd312f16647605e1ec799550cb90c3aa902fd..c9056288a5df1674204aec124951e6d959363f38 100644 (file)
@@ -650,7 +650,7 @@ core::audio_channel_layout get_audio_channel_layout(const AVCodecContext& codec_
                        auto layout = core::audio_channel_layout_repository::get_default()->get_layout(channel_layout_spec);
 
                        if (!layout)
-                               CASPAR_THROW_EXCEPTION(invalid_argument() << msg_info(L"No channel layout with name " + channel_layout_spec + L" registered"));
+                               CASPAR_THROW_EXCEPTION(user_error() << msg_info(L"No channel layout with name " + channel_layout_spec + L" registered"));
 
                        layout->num_channels = num_channels;
 
index 1023b551d8b6b561a3ef2a15b4b441f1792371c3..9270422925653e57cdc0bd42d6b5e2d6e4282a05 100644 (file)
@@ -101,8 +101,8 @@ struct image_scroll_producer : public core::frame_producer_base
                bool horizontal = height_ == format_desc_.height;
 
                if (!vertical && !horizontal)
-                       CASPAR_THROW_EXCEPTION(
-                               caspar::invalid_argument() << msg_info("Neither width nor height matched the video resolution"));
+                       CASPAR_THROW_EXCEPTION(caspar::user_error()
+                                       << msg_info("Neither width nor height matched the video resolution"));
 
                if (vertical)
                {
index 139a4040db4f18149ed88c563f27862231c30869..feade373c45b12e5f5f7e752cb8e012cecc9e9ff 100644 (file)
@@ -66,7 +66,7 @@ public:
                : executor_(print())
        {
                if (!airsend::is_available())
-                       CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info(airsend::dll_name() + L" not available"));
+                       CASPAR_THROW_EXCEPTION(not_supported() << msg_info(airsend::dll_name() + L" not available"));
 
                connected_ = false;
 
index 361bf1abecea7d782e0800afc8db667b2d838c7b..1458b128a3fe586de26a5136a368ee078c99c4bd 100644 (file)
@@ -306,7 +306,7 @@ spl::shared_ptr<core::frame_consumer> create_consumer(const std::vector<std::wst
                auto found_layout = core::audio_channel_layout_repository::get_default()->get_layout(channel_layout_spec);
 
                if (!found_layout)
-                       CASPAR_THROW_EXCEPTION(file_not_found() << msg_info(L"Channel layout " + channel_layout_spec + L" not found."));
+                       CASPAR_THROW_EXCEPTION(user_error() << msg_info(L"Channel layout " + channel_layout_spec + L" not found."));
 
                channel_layout = *found_layout;
        }
@@ -326,7 +326,7 @@ spl::shared_ptr<core::frame_consumer> create_preconfigured_consumer(const boost:
                auto found_layout = core::audio_channel_layout_repository::get_default()->get_layout(*channel_layout_spec);
 
                if (!found_layout)
-                       CASPAR_THROW_EXCEPTION(file_not_found() << msg_info(L"Channel layout " + *channel_layout_spec + L" not found."));
+                       CASPAR_THROW_EXCEPTION(user_error() << msg_info(L"Channel layout " + *channel_layout_spec + L" not found."));
 
                channel_layout = *found_layout;
        }
index 4241bc7dd19ac0ac075fa1575f2acc33f7cdaf83..54614d428acdd437fe90080dd590be6a37c385a5 100644 (file)
@@ -81,7 +81,7 @@ spl::shared_ptr<core::frame_producer> create_producer(
        auto found_channel = boost::find_if(dependencies.channels, [=](spl::shared_ptr<core::video_channel> ch) { return ch->index() == channel_id; });
 
        if (found_channel == dependencies.channels.end())
-               CASPAR_THROW_EXCEPTION(file_not_found() << msg_info(L"No channel with id " + channel_id));
+               CASPAR_THROW_EXCEPTION(user_error() << msg_info(L"No channel with id " + boost::lexical_cast<std::wstring>(channel_id)));
 
        if (has_layer_spec)
        {
index e4ca1f932f094d8e70a10290af228dc1f7a55e0e..ddfa8c58f5058d53531fcfd23d34342940fe1582 100644 (file)
@@ -111,21 +111,27 @@ void AMCPCommandQueue::AddCommand(AMCPCommand::ptr_type pCurrentCommand)
                        catch (file_not_found&)
                        {
                                CASPAR_LOG_CURRENT_EXCEPTION_AT_LEVEL(debug);
-                               CASPAR_LOG(error) << L"File not found. No match found for parameters. Check syntax.";
+                               CASPAR_LOG(error) << L"File not found. No match found for parameters. Check syntax. Turn on log level debug for stacktrace.";
                                pCurrentCommand->SetReplyString(L"404 " + pCurrentCommand->print() + L" FAILED\r\n");
                        }
                        catch (const user_error& e)
                        {
                                CASPAR_LOG_CURRENT_EXCEPTION_AT_LEVEL(debug);
-                               CASPAR_LOG(error) << *boost::get_error_info<msg_info_t>(e) << ". Check syntax.";
+                               CASPAR_LOG(error) << *boost::get_error_info<msg_info_t>(e) << ". Check syntax. Turn on log level debug for stacktrace.";
                                pCurrentCommand->SetReplyString(L"403 " + pCurrentCommand->print() + L" FAILED\r\n");
                        }
                        catch (std::out_of_range&)
                        {
                                CASPAR_LOG_CURRENT_EXCEPTION_AT_LEVEL(debug);
-                               CASPAR_LOG(error) << L"Missing parameter. Check syntax.";
+                               CASPAR_LOG(error) << L"Missing parameter. Check syntax. Turn on log level debug for stacktrace.";
                                pCurrentCommand->SetReplyString(L"402 " + pCurrentCommand->print() + L" FAILED\r\n");
                        }
+                       catch (boost::bad_lexical_cast&)
+                       {
+                               CASPAR_LOG_CURRENT_EXCEPTION_AT_LEVEL(debug);
+                               CASPAR_LOG(error) << L"Invalid parameter. Check syntax. Turn on log level debug for stacktrace.";
+                               pCurrentCommand->SetReplyString(L"403 " + pCurrentCommand->print() + L" FAILED\r\n");
+                       }
                        catch (...)
                        {
                                CASPAR_LOG_CURRENT_EXCEPTION();
index e0c9504e7a223d3e616b52f6c13b1c4a66028b97..d23cb6f54d6bc4ab21a5e50dbc6f74851a261674 100644 (file)
@@ -731,7 +731,7 @@ std::wstring set_command(command_context& ctx)
                        return L"202 SET MODE OK\r\n";
                }
 
-               CASPAR_THROW_EXCEPTION(invalid_argument() << msg_info(L"Invalid video mode"));
+               CASPAR_THROW_EXCEPTION(user_error() << msg_info(L"Invalid video mode"));
        }
        else if (name == L"CHANNEL_LAYOUT")
        {
@@ -743,10 +743,10 @@ std::wstring set_command(command_context& ctx)
                        return L"202 SET CHANNEL_LAYOUT OK\r\n";
                }
 
-               CASPAR_THROW_EXCEPTION(invalid_argument() << msg_info(L"Invalid audio channel layout"));
+               CASPAR_THROW_EXCEPTION(user_error() << msg_info(L"Invalid audio channel layout"));
        }
 
-       CASPAR_THROW_EXCEPTION(invalid_argument() << msg_info(L"Invalid channel variable"));
+       CASPAR_THROW_EXCEPTION(user_error() << msg_info(L"Invalid channel variable"));
 }
 
 void data_store_describer(core::help_sink& sink, const core::help_repository& repo)
@@ -899,17 +899,6 @@ std::wstring data_remove_command(command_context& ctx)
 
 // Template Graphics Commands
 
-int get_and_validate_layer(const std::wstring& layerstring) {
-       int length = layerstring.length();
-       for (int i = 0; i < length; ++i) {
-               if (!std::isdigit(layerstring[i])) {
-                       CASPAR_THROW_EXCEPTION(invalid_argument() << msg_info(layerstring + L" is not a layer"));
-               }
-       }
-
-       return boost::lexical_cast<int>(layerstring);
-}
-
 void cg_add_describer(core::help_sink& sink, const core::help_repository& repo)
 {
        sink.short_description(L"Prepare a template for displaying.");
@@ -925,7 +914,7 @@ std::wstring cg_add_command(command_context& ctx)
 {
        //CG 1 ADD 0 "template_folder/templatename" [STARTLABEL] 0/1 [DATA]
 
-       int layer = get_and_validate_layer(ctx.parameters.at(0));
+       int layer = boost::lexical_cast<int>(ctx.parameters.at(0));
        std::wstring label;             //_parameters[2]
        bool bDoStart = false;          //_parameters[2] alt. _parameters[3]
        unsigned int dataIndex = 3;
@@ -994,7 +983,7 @@ void cg_play_describer(core::help_sink& sink, const core::help_repository& repo)
 
 std::wstring cg_play_command(command_context& ctx)
 {
-       int layer = get_and_validate_layer(ctx.parameters.at(0));
+       int layer = boost::lexical_cast<int>(ctx.parameters.at(0));
        ctx.cg_registry->get_proxy(spl::make_shared_ptr(ctx.channel.channel), ctx.layer_index(core::cg_proxy::DEFAULT_LAYER))->play(layer);
 
        return L"202 CG OK\r\n";
@@ -1023,7 +1012,7 @@ void cg_stop_describer(core::help_sink& sink, const core::help_repository& repo)
 
 std::wstring cg_stop_command(command_context& ctx)
 {
-       int layer = get_and_validate_layer(ctx.parameters.at(0));
+       int layer = boost::lexical_cast<int>(ctx.parameters.at(0));
        get_expected_cg_proxy(ctx)->stop(layer, 0);
 
        return L"202 CG OK\r\n";
@@ -1042,7 +1031,7 @@ void cg_next_describer(core::help_sink& sink, const core::help_repository& repo)
 
 std::wstring cg_next_command(command_context& ctx)
 {
-       int layer = get_and_validate_layer(ctx.parameters.at(0));
+       int layer = boost::lexical_cast<int>(ctx.parameters.at(0));
        get_expected_cg_proxy(ctx)->next(layer);
 
        return L"202 CG OK\r\n";
@@ -1059,7 +1048,7 @@ void cg_remove_describer(core::help_sink& sink, const core::help_repository& rep
 
 std::wstring cg_remove_command(command_context& ctx)
 {
-       int layer = get_and_validate_layer(ctx.parameters.at(0));
+       int layer = boost::lexical_cast<int>(ctx.parameters.at(0));
        get_expected_cg_proxy(ctx)->remove(layer);
 
        return L"202 CG OK\r\n";
@@ -1090,7 +1079,7 @@ void cg_update_describer(core::help_sink& sink, const core::help_repository& rep
 
 std::wstring cg_update_command(command_context& ctx)
 {
-       int layer = get_and_validate_layer(ctx.parameters.at(0));
+       int layer = boost::lexical_cast<int>(ctx.parameters.at(0));
 
        std::wstring dataString = ctx.parameters.at(1);
        if (dataString.at(0) != L'<' && dataString.at(0) != L'{')
@@ -1120,7 +1109,7 @@ std::wstring cg_invoke_command(command_context& ctx)
 {
        std::wstringstream replyString;
        replyString << L"201 CG OK\r\n";
-       int layer = get_and_validate_layer(ctx.parameters.at(0));
+       int layer = boost::lexical_cast<int>(ctx.parameters.at(0));
        auto result = get_expected_cg_proxy(ctx)->invoke(layer, ctx.parameters.at(1));
        replyString << result << L"\r\n";
 
@@ -1147,7 +1136,7 @@ std::wstring cg_info_command(command_context& ctx)
        }
        else
        {
-               int layer = get_and_validate_layer(ctx.parameters.at(0));
+               int layer = boost::lexical_cast<int>(ctx.parameters.at(0));
                auto desc = get_expected_cg_proxy(ctx)->description(layer);
 
                replyString << desc << L"\r\n";
@@ -2157,7 +2146,7 @@ std::wstring thumbnail_generate_command(command_context& ctx)
                return L"202 THUMBNAIL GENERATE OK\r\n";
        }
        else
-               CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info(L"Thumbnail generation turned off"));
+               CASPAR_THROW_EXCEPTION(not_supported() << msg_info(L"Thumbnail generation turned off"));
 }
 
 void thumbnail_generateall_describer(core::help_sink& sink, const core::help_repository& repo)
@@ -2175,7 +2164,7 @@ std::wstring thumbnail_generateall_command(command_context& ctx)
                return L"202 THUMBNAIL GENERATE_ALL OK\r\n";
        }
        else
-               CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info(L"Thumbnail generation turned off"));
+               CASPAR_THROW_EXCEPTION(not_supported() << msg_info(L"Thumbnail generation turned off"));
 }
 
 // Query Commands
index d5decb68c061c2bb4955192515ac3378da237de1..92b370838f0bd39e332e8f31e53e898d37f15af3 100644 (file)
@@ -323,10 +323,16 @@ int main(int argc, char** argv)
                if (!should_wait_for_keypress)
                        wait_for_keypress();
        }
-       catch(boost::property_tree::file_parser_error&)
+       catch(const boost::property_tree::file_parser_error& e)
        {
                CASPAR_LOG_CURRENT_EXCEPTION();
-               CASPAR_LOG(fatal) << L"Unhandled configuration error in main thread. Please check the configuration file (" << config_file_name << L") for errors.";
+               CASPAR_LOG(fatal) << "At " << u8(config_file_name) << ":" << e.line() << ": " << e.message() << ". Please check the configuration file (" << u8(config_file_name) << ") for errors.";
+               wait_for_keypress();
+       }
+       catch (const user_error& e)
+       {
+               CASPAR_LOG_CURRENT_EXCEPTION_AT_LEVEL(debug);
+               CASPAR_LOG(fatal) << *boost::get_error_info<msg_info_t>(e) << ". Please check the configuration file (" << u8(config_file_name) << ") for errors. Turn on log level debug for stacktrace.";
                wait_for_keypress();
        }
        catch(...)
index 0523618e4410c8522b96a2ac22a84d5e3083574a..9f9c159470e2aa412dfca3ea55bd53e830759403 100644 (file)
@@ -242,14 +242,16 @@ struct server::impl : boost::noncopyable
        {   
                using boost::property_tree::wptree;
                for (auto& xml_channel : pt.get_child(L"configuration.channels"))
-               {               
-                       auto format_desc = video_format_desc(xml_channel.second.get(L"video-mode", L"PAL"));
+               {
+                       auto format_desc_str = xml_channel.second.get(L"video-mode", L"PAL");
+                       auto format_desc = video_format_desc(format_desc_str);
                        if(format_desc.format == video_format::invalid)
-                               CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info("Invalid video-mode."));
+                               CASPAR_THROW_EXCEPTION(user_error() << msg_info(L"Invalid video-mode: " + format_desc_str));
 
-                       auto channel_layout = core::audio_channel_layout_repository::get_default()->get_layout(xml_channel.second.get(L"channel-layout", L"stereo"));
+                       auto channel_layout_str = xml_channel.second.get(L"channel-layout", L"stereo");
+                       auto channel_layout = core::audio_channel_layout_repository::get_default()->get_layout(channel_layout_str);
                        if (!channel_layout)
-                               CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info("Unknown channel-layout."));
+                               CASPAR_THROW_EXCEPTION(user_error() << msg_info(L"Unknown channel-layout: " + channel_layout_str));
 
                        auto channel_id = static_cast<int>(channels_.size() + 1);
                        auto channel = spl::make_shared<video_channel>(channel_id, format_desc, *channel_layout, accelerator_.create_image_mixer(channel_id));
@@ -259,14 +261,19 @@ struct server::impl : boost::noncopyable
                        
                        for (auto& xml_consumer : xml_channel.second.get_child(L"consumers"))
                        {
+                               auto name = xml_consumer.first;
+
                                try
                                {
-                                       auto name = xml_consumer.first;
-                                       
                                        if (name != L"<xmlcomment>")
                                                channel->output().add(consumer_registry_->create_consumer(name, xml_consumer.second, &channel->stage()));
                                }
-                               catch(...)
+                               catch (const user_error& e)
+                               {
+                                       CASPAR_LOG_CURRENT_EXCEPTION_AT_LEVEL(debug);
+                                       CASPAR_LOG(error) << *boost::get_error_info<msg_info_t>(e) << L". Error found in " << name << L" consumer configuration. Turn on log level debug for stacktrace.";
+                               }
+                               catch (...)
                                {
                                        CASPAR_LOG_CURRENT_EXCEPTION();
                                }
@@ -375,30 +382,23 @@ struct server::impl : boost::noncopyable
                using boost::property_tree::wptree;
                for (auto& xml_controller : pt.get_child(L"configuration.controllers"))
                {
-                       try
-                       {
-                               auto name = xml_controller.first;
-                               auto protocol = xml_controller.second.get<std::wstring>(L"protocol");   
-
-                               if(name == L"tcp")
-                               {                                       
-                                       unsigned int port = xml_controller.second.get(L"port", 5250);
-                                       auto asyncbootstrapper = spl::make_shared<IO::AsyncEventServer>(
-                                                       io_service_,
-                                                       create_protocol(protocol, L"TCP Port " + boost::lexical_cast<std::wstring>(port)),
-                                                       port);
-                                       async_servers_.push_back(asyncbootstrapper);
-
-                                       if (!primary_amcp_server_ && boost::iequals(protocol, L"AMCP"))
-                                               primary_amcp_server_ = asyncbootstrapper;
-                               }
-                               else
-                                       CASPAR_LOG(warning) << "Invalid controller: " << name;  
-                       }
-                       catch(...)
-                       {
-                               CASPAR_LOG_CURRENT_EXCEPTION();
+                       auto name = xml_controller.first;
+                       auto protocol = xml_controller.second.get<std::wstring>(L"protocol");   
+
+                       if(name == L"tcp")
+                       {                                       
+                               unsigned int port = xml_controller.second.get(L"port", 5250);
+                               auto asyncbootstrapper = spl::make_shared<IO::AsyncEventServer>(
+                                               io_service_,
+                                               create_protocol(protocol, L"TCP Port " + boost::lexical_cast<std::wstring>(port)),
+                                               port);
+                               async_servers_.push_back(asyncbootstrapper);
+
+                               if (!primary_amcp_server_ && boost::iequals(protocol, L"AMCP"))
+                                       primary_amcp_server_ = asyncbootstrapper;
                        }
+                       else
+                               CASPAR_LOG(warning) << "Invalid controller: " << name;  
                }
        }
 
@@ -417,7 +417,7 @@ struct server::impl : boost::noncopyable
                else if (boost::iequals(name, L"LOG"))
                        return spl::make_shared<protocol::log::tcp_logger_protocol_strategy_factory>();
 
-               CASPAR_THROW_EXCEPTION(caspar_exception() << arg_name_info(L"name") << arg_value_info(name) << msg_info(L"Invalid protocol"));
+               CASPAR_THROW_EXCEPTION(user_error() << msg_info(L"Invalid protocol: " + name));
        }
 
        void start_initial_media_info_scan()
index 668d210affc506f6305b0edb683c08d2efc7b801..65eec64c456b91092fcfaae2fad3135721565c5b 100644 (file)
@@ -124,6 +124,7 @@ void increase_process_priority()
 
 void wait_for_keypress()
 {
+       boost::this_thread::sleep_for(boost::chrono::milliseconds(200));
        std::system("pause");
 }