Warning/Error handling from complex, sparse array on SVD (PROPACK)

Let’s assume I have a sparse matrix with complex entries.
I want to perform svd on it. So, I use the Propack package (do you have any better suggestions?).
I do this with the command: tsvdvals(gs, k=p), where I retain the p largest singular values of matrix gs.
Now, depending on the input matrix, there are some errors that come out which I do not know how to handle. For example, for a given matrix, I get the following:

WARNING: Maximum dimension of Krylov subspace exceeded prior to convergence. Try increasing KMAX.
 neig =                    13
ERROR: lansvd return code: -1

This means I used very big value for p and I have to decrease it to 13 in this situation. However, this value depends on the given matrix used.

The question: How can I handle the warning message, save it (the value 13 of the second line of the warning) to a given variable and use it for updating the calculation for the correct value of p?