Slide 28
Slide 28 text
Copyright (C) 2023 Toranoana Lab Inc. All Rights Reserved. #jjug_ccc_abc
UserService userService = new UserService();
try {
userService.createUser("test", 25);
userService.findByName("test");
return renderUserDetail();
} catch (UserExceptionBase e) {
return switch (e) {
case UserNotFoundException ex -> renderNotFound();
case UserNotUniqueException ex -> renderParamError();
}
}
パターンマッチによる分岐
28