1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| package com.oying.exception;
|
| import org.springframework.util.StringUtils;
|
| /**
| * @author Z
| * @date 2018-11-23
| */
| public class EntityExistException extends RuntimeException {
|
| public EntityExistException(Class clazz, String field, String val) {
| super(EntityExistException.generateMessage(clazz.getSimpleName(), field, val));
| }
|
| private static String generateMessage(String entity, String field, String val) {
| return StringUtils.capitalize(entity)
| + " with " + field + " "+ val + " existed";
| }
| }
|
|