In Apex I have this:
...
if (forceException) {
Integer a = 1/0;
}
...
But after I ran SFDX Scanner
I got an error that variable a
is defined but not used (UnusedLocalVariable) so I decided to do next thing:
...
if (forceException) {
throw new Exception('Exception');
}
...
but now I had problem because pipeline
throw me next error:
Type cannot be constructed: Exception
does anyone know is there any other option what I can use in if statement instead of throw new Exception('Exception');
and Integer a = 1/0;
?