Kevin Gorham
05/15/2020, 5:30 PMif (error != null) throw error
Casey Brooks
05/15/2020, 5:33 PMerror?.let { throw it }
jw
05/15/2020, 6:06 PMKevin Gorham
05/15/2020, 8:47 PMthrow
that make this feel more awkward than other, similar code. Parameters that are exceptions are often nullable. I almost wish that throw null
did nothing or error?.throw
worked.
I'm fine writing the lengthier version, I just had a suspicion that there might be some other stdlib approach out there that I didn't know about.Arkadii Ivanov
05/16/2020, 12:23 AMDerek Peirce
05/16/2020, 3:11 AMthrow null
worked, then everywhere a throw e
occured, I would have to double-check that e
is non-null, or else it isn't a guaranteed throw and the remaining code in that block might still happen.jw
05/16/2020, 3:45 PMthrow null
works in Java and in Java bytecode as an easy way to throw an NPEE.Kisaragi
05/16/2020, 8:23 PM