On Wed, Oct 08, 2014 at 09:28:39PM +0200, Lennart Poettering wrote: > On Wed, 08.10.14 17:24, Zbigniew Jędrzejewski-Szmek (zbys...@in.waw.pl) wrote: > > > > > I think that the best way to handle this would be to > > > > use a temporary structure like > > > > { char *unit_name; char *error_message; int code} > > > > and use this to pass the information about the error from the lower > > > > to the upper levels. But maybe I'm overcomplicating things. > > > > > > Hmm, maybe a simply solution would be to convert EADDRNOTAVAIL into a > > > proper sd_bus_error on the calling side, that shouldn't be too > > > difficult. > > > > You can convert to an error, sure, but it is really nice to deliver > > a specific message like "Unit boo.service is masked", instead of > > "A unit is masked". > > Well, true, but then again, it's not thaaaaaat much worse... Yeah, I guess now its time to do a proof-of-concept implementation to see how it works in practice. > > > > A related thing: there's a mapping bus-error <-> errno implemented, > > > > but it only works for the errors defined in the library itself. It > > > > would be nice to extend this mapping to the "user" defined errors, > > > > e.g. in core/. Would you be amenable to adding a mechianism to > > > > register additional mappings like bus-error-mapping.gperf so that they > > > > are used by the library? > > > > > > Maybe have internal versions of the conversion calls that allow > > > passing in an additional table? > > That is not as convenient. E.g. sd_bus_error_set > > internally calls bus_error_name_to_errno. Currently, this always > > returns EIO for errors unknown to the library, and then the caller > > does it own lookup (e.g. looking at transaction_add_job_and_dependencies()). > > What precisely are you proposing instead?
typedef const name_error_mapping* (*bus_error_mapping_lookup_t) (const char *str, size_t len); int bus_error_add_mapping(bus_error_mapping_lookup_t mapping); This could be used to register a custom function similar to our bus_error_mapping_lookup(). It would get stored in a global table (of fixed size?), and bus_error_mapping_lookup would be the first slot in this table and the calls to bus_error_mapping_lookup would be replace by a function which iterates over this table and returns the first successful lookup. Zbyszek _______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel