Add more error handling and warnings. Doing this nicely requires a bit of re-work to the control flow. Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>