Foren

Code Exceptions Correctly...

thumbnail
David H Nebinger, geändert vor 9 Jahren.

Code Exceptions Correctly...

Liferay Legend Beiträge: 14919 Beitrittsdatum: 02.09.06 Neueste Beiträge
I really hate the stupid output for a Liferay exception:

null
com.liferay.portal.RequiredFieldException
    at ...


Why is it so freaking hard to actually code something into getMessage() or toString() that might actually make seeing those guys in the log worthwhile?
thumbnail
Jorge Ferrer, geändert vor 9 Jahren.

RE: Code Exceptions Correctly...

Liferay Legend Beiträge: 2871 Beitrittsdatum: 31.08.06 Neueste Beiträge
Fully agreed.

We have started some work to improve the information available in exceptions, which is useful for logging purposes but also to provide more valuable info in the UI. You can see some progress here: https://issues.liferay.com/browse/LPS-47130

However I must say that while working on this we ended up concluding that long term we should put our emphasis into a better API design that does validation in a different way. That's much more ambitious and probably won't make it into Liferay 7 but we will at least have a proof of concept.
thumbnail
David H Nebinger, geändert vor 9 Jahren.

RE: Code Exceptions Correctly...

Liferay Legend Beiträge: 14919 Beitrittsdatum: 02.09.06 Neueste Beiträge
Glad to hear it's getting addressed, although it's not just the validation exceptions I'm concerned about. Many of the Liferay exceptions, as I'm sure you know, are basically treated like data containers to pass data from a bottom layer to an upper layer and therefore they lack a meaningful display value if logged even when the data they contain has value...
thumbnail
Jorge Ferrer, geändert vor 9 Jahren.

RE: Code Exceptions Correctly...

Liferay Legend Beiträge: 2871 Beitrittsdatum: 31.08.06 Neueste Beiträge
Hey David,

Yeah, if you look at the LPS I pointed too you will notice that the new pattern is for exceptions in general. I mentioned validation specifically since your example was about that and we will actually try to avoid exceptions for that in the far-future design.

BTW, if you have specific exceptions where you are seeing this negative effect let us know and we can try to prioritize doing those first.
thumbnail
David H Nebinger, geändert vor 9 Jahren.

RE: Code Exceptions Correctly...

Liferay Legend Beiträge: 14919 Beitrittsdatum: 02.09.06 Neueste Beiträge
Jorge Ferrer:
BTW, if you have specific exceptions where you are seeing this negative effect let us know and we can try to prioritize doing those first.


Thanks, Jorge, I don't know what I did to deserve such prioritization, but I appreciate it emoticon