Mini articles/java unknown stack trace (#11627)
* unknown source in stack trace * Improved comment * creating an intentional exception Co-authored-by: Sameer <d7495b5879fca1ec1367476a5395a60a8e9baec9>
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package com.baeldung.unknownsourcestacktrace;
|
||||
|
||||
import com.baeldung.unknownsourcestacktrace.dto.User;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class Main {
|
||||
private static final Logger logger = LoggerFactory.getLogger(Main.class);
|
||||
private static final int SHORT_NAME_LIMIT = 10;
|
||||
|
||||
public static void main(String[] args) {
|
||||
User user = new User();
|
||||
user.setName("Tom");
|
||||
|
||||
logger.info(getGreetingMessage(user.getName()));
|
||||
}
|
||||
|
||||
private static String getGreetingMessage(String name) {
|
||||
return "Welcome " + getShortenedName(name) + "!";
|
||||
}
|
||||
|
||||
private static String getShortenedName(String name) {
|
||||
return name.substring(0, SHORT_NAME_LIMIT);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.baeldung.unknownsourcestacktrace.dto;
|
||||
|
||||
public class User {
|
||||
private String name;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user