Daily Debug
Mar 28, 2024

In the example provided in the article, we have created CustomError model class which has msg and errorCode as parameters.

So while throwing exceptions we can set different msg for different context


CustomError error = new CustomError();
error.setErrorCode(HttpStatus.INTERNAL_SERVER_ERROR.value());
error.sets("Arithmetic exception thrown " + ae.getLocalizedMessage());


Here error.sets(any custom msg) can be used to set custom mags.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Daily Debug
Daily Debug

Written by Daily Debug

I am software engineer, Technical Content Writer, here to help you learn and share my insights on various tech topics.

No responses yet

Write a response