edtlib: improve error handling paths Miscellaneous fixes discovered by inspection while type annotating the module. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>