As pointed out by Yksisarvinen, the new keyword works differently in java and c++.
I removed the new and I am now able to catch the exception.
solved I have a custom exception I want to throw in one function and catch in another, it isn’t working [closed]