[] (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;
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;
}
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()));
}
}
}
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()));
}
}
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)
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;
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>(
{
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;
}();
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)
});
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)
{
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
{
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);
}
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()));
}
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();}
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
}
}
- 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));
}
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;
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;
++cursor;
}
- CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info(
+ CASPAR_THROW_EXCEPTION(user_error() << msg_info(
L"Unexpected end of input (Expected closing \") in " + str));
}
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)));
}
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;
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;
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;
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;
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;
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;
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;
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));
}
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())));
}
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())));
}
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())));
}
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);
}
if (tokens.empty())
- CASPAR_THROW_EXCEPTION(caspar_exception()
+ CASPAR_THROW_EXCEPTION(user_error()
<< msg_info(L"Expected expression"));
int precedence = 1;
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())));
-}*/
-
}}}
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())));
}
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
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;
}
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"";
}
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
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));
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();
}
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;
}
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;
}
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;
}
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);
}
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"));
}
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"));
}
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.";
}
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_)
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;}
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;
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;
}
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;
}
{
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;
}
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;
}
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);
}
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;
}
}
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);
}
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;
}
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;
}
{
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;
{
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;
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;
}
: 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>(
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;
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)
{
: 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;
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;
}
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;
}
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)
{
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();
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")
{
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)
// 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.");
{
//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;
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";
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";
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";
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";
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'{')
{
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";
}
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";
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)
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
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(...)
{
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));
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();
}
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;
}
}
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()
void wait_for_keypress()
{
+ boost::this_thread::sleep_for(boost::chrono::milliseconds(200));
std::system("pause");
}