I have my model class with constructor that can throw exceptions:
public class BookModel {
private Book book;
String authorName;
public BookModel(Book book) {
this.book = book;
try {
this.authorName = (AuthorLocalServiceUtil.getAuthor(book.getAuthorId())).getAuthorName();
} catch (PortalException | SystemException e) {
e.printStackTrace();
}
}
After that, I create new object here:
for (Book book: bookList) {
books.add(new BookModel(book));
}
So my question is, should I catch my exception in constructor or in the moment of object's initialization? Im very newbie so I really need your help.