Replace an option with a result type.

We want all unmarshalling code to return a debuggable error rather
than simply 'None'.

Signed-off-by: David Scott <dave.scott@eu.citrix.com>