Here is the code snippet :
myObject[] array = Arrays.copyOf(original, original.length, myObject[].class);
Is it okay to catch exception instead of checking original against null?
Here is the code snippet :
myObject[] array = Arrays.copyOf(original, original.length, myObject[].class);
Is it okay to catch exception instead of checking original against null?
It's generally not a good idea to catch exceptions unless your expecting that a particular type of exception might occur. (e.g. email already in system might throw a validation exception, or if data is not found you might get a BadRequest exception)
When applicable, like it seems likely in your snippet, it would be better to do a null check and direct to two different flows depending on what is found. Alternatively, you could instantiate a new array if none is found.
Checking If (value == null) advantages against exception block