Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Andre Kucharzyk
4,479 PointsException placement in logs.
public class Main {
public static void yell(String words) {
Objects.requireNonNull(words, () -> "Created issue" + Main.createIssue());
System.out.printf("%s!!!!! %n", words.toUpperCase());
}
private static String createIssue() {
System.out.println("Some external API call to bug tracker");
return "#135345";
}
public static void main(String[] args) {
List<String> ingredients = Arrays.asList(
"dupa",
"nie dupa",
"znowu nie dupa",
"cycki",
null
);
ingredients.forEach(Main::yell);
}
}
LOGS FROM CONSOLE:
Exception in thread "main" java.lang.NullPointerException: Created issue#135345 NIE DUPA!!!!! at java.base/java.util.Objects.requireNonNull(Objects.java:347) at Main.yell(Main.java:10) at java.base/java.util.Arrays$ArrayList.forEach(Arrays.java:4389) at Main.main(Main.java:28) ZNOWU NIE DUPA!!!!! CYCKI!!!!! Some external API call to bug tracker
My question is - why excepion in logs is shown after word "DUPA!!!!!" and not below "CYCKI" where the null is?
Andre Kucharzyk
4,479 PointsAndre Kucharzyk
4,479 PointsBy the way - when I copy paste logs from InteliJ console they lose formatting (everything is in single line). Is there a way to fix it?