src: only access stack of non-null errors

Avoid segmentation fault when `null` is thrown