supress panic and gracefully return an error