Home > Back-end >  Small white for bosses help me solve the problem!
Small white for bosses help me solve the problem!

Time:10-29

Springboot project, write the service implementation class at present Unreachable code wrong
What is the cause?

CodePudding user response:

Found the reason, if one wrote; Behind the implementation will be an error

CodePudding user response:

reference 1/f, best wishes proud boy reply:
reason found, if one wrote; Led to the back less than before, an


You throw the exception above, the following code to can not run, so the waste code below! UNreachable, can't get the meaning of!

CodePudding user response:

the if (); Ended the if the back of the; Removed, as the following:

If (StringUtils. IsEmpty (entity. GetName)) throw new ServiceException (" department name cannot be empty ");

After multiple don't change the if () directly with statements, this format is called who expression, specifications, if behind the if there is only one statement, suggest don't break, more neat format

CodePudding user response:

refer to the second floor ryuukasenn response:
Quote: best wishes reference 1/f, proud boy reply:

Found the reason, if one wrote; Led to the back less than before, an


You throw the exception above, the following code to can not run, so the waste code below! UNreachable, can't get the meaning of!
understand, thank you for your answer

CodePudding user response:

keep reference 3 floor - go - on response:
the if (); Ended the if the back of the; Removed, as the following:

If (StringUtils. IsEmpty (entity. GetName)) throw new ServiceException (" department name cannot be empty ");

Directly with multiple don't change the if () statement, called guard expression, this format specifications, if behind the if only one statement, is not recommended a newline, format more neatly
understand, thank you very much against!
  • Related