makelinks: add better error handling

Change-Id: Ie972c6345e1f842072338ca597b098a83c22243f