Skip to content

Instantly share code, notes, and snippets.

@sebastienvermeille
Created June 17, 2019 19:34
Show Gist options
  • Save sebastienvermeille/1d45cb456a1e5040161efbea520b40b2 to your computer and use it in GitHub Desktop.
Save sebastienvermeille/1d45cb456a1e5040161efbea520b40b2 to your computer and use it in GitHub Desktop.
public UserService {
public User register(
@NonNull final String username,
@NonNull final String plainPassword,
@NonNull final Email email,
@NonNull final LocalDate birthDate,
@NonNull final Gender gender) throws UnableToSaveUserException {}
}
// multiple exception can occurs as source of UnableToSaveUserException
public class UnableToSaveUserException extends Exception {}
public class UsernameAlreadyRegisteredException extends UnableToSaveUserException {}
public class EmailAlreadyRegisteredException extends UnableToSaveUserException {}
public class NotWellFormedUserDtoException extends UnableToSaveUserException {}
public class UserNotAuthorizedToPerformOperation extends RuntimeException {} // should it be a checked exception ????
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment