os/session_policy: warn if no policy exists

The situation where a 'Session_policy' is constructed for a label with
no matching policy is in almost all cases a configuration problem.
A diagnostic message eases pin-pointing such mistaks. By adding the
message to the 'Session_policy', servers don't need to manually handle
the exception to provide diagnostic information. This simplifies the
server code in many components.
This commit is contained in:
Norman Feske 2019-01-22 18:57:22 +01:00
parent f529871162
commit d3759811b6
4 changed files with 5 additions and 0 deletions

View File

@ -12,6 +12,7 @@
<resource name="RAM" quantum="8M"/>
<config>
<controls> <maximizer/> <title/> </controls>
<default-policy/>
</config>
<route>
<service name="ROM" label="window_layout"> <parent label="window_layout"/> </service>

View File

@ -45,6 +45,7 @@
<config>
<policy label_prefix="decorator" role="decorator"/>
<policy label_prefix="layouter" role="layouter"/>
<default-policy/>
</config>
<route>
<service name="ROM" label="resize_request"> <child name="report_rom"/> </service>

View File

@ -14,6 +14,7 @@
<config>
<libc/>
<vfs> <tar name="plain_decorator_theme.tar"/> </vfs>
<default-policy/>
</config>
<route>
<service name="ROM" label="window_layout"> <parent label="window_layout"/> </service>

View File

@ -15,6 +15,7 @@
#define _INCLUDE__OS__SESSION_POLICY_H_
#include <base/session_label.h>
#include <base/log.h>
#include <session/session.h>
#include <util/arg_string.h>
#include <util/xml_node.h>
@ -199,6 +200,7 @@ class Genode::Session_policy : public Xml_node
try { return config.sub_node("default-policy"); }
catch (...) { }
warning("no policy defined for label '", label, "'");
throw No_policy_defined();
}