I don't like playing with Exceptions in that way, I think you should rather do something like

 RevObject any = rw.parseAny(ref.getLeaf().getObjectId());
 if (any instanceof RevCommit) {
 	// it's a lightweight tag
 } else if (any instanceof RevTag) {
 	// it's an annotated or signed tag
 }