Why `SerializationException` is marked as `Swallow...
# detekt
j
Why
SerializationException
is marked as
SwallowedException
? Even being open,
public open class SerializationException : IllegalArgumentException
, the child exceptions are
internal
. Should I file a feature request for this as it is the kotlinx serialization library?
b
I'm not too familiar with that exception. Is it usual to catch it and just provide a default value? For example, you should catch
MalformedURLException
to know if an String is a well-formed URL.
There are good reasons to catch and shallow nearly any type of exception but we should just add on the default values those that you clearly want to shallow. The configuration even point out to Java apis that are meant to be used like that.
And if the exception comes from the serialization library I think that we will not add it as a default value to keep detekt library agnostic.
j
I can't catch further than
SerializationException
as the nested classes are internal, that is the most specific one. I understand the part of being agnostic, but at the same time even serialization library being outside of stdlib, I think detekt should try them as official libraries in a way to react to them specifically, but that can be a hard work as there are tons of kotlinx libraries too...
b
ShallowedException
doesn't complain about you catching the exception itself. It will complain even if you could catch the more specific ones. It's complaining that you are catching it and you aren't doing anything with it.
j
Oh that explain all, thanks!