Blame view

src/main/java/com/canrd/webmagic/common/exception/EntityNotFoundException.java 568 Bytes
谢茂盛 authored
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package com.canrd.webmagic.common.exception;

import org.springframework.util.StringUtils;

/**
 *
 * @date 2018-11-23
 */
public class EntityNotFoundException extends RuntimeException {

    public EntityNotFoundException(Class clazz, String field, String val) {
        super(EntityNotFoundException.generateMessage(clazz.getSimpleName(), field, val));
    }

    private static String generateMessage(String entity, String field, String val) {
        return StringUtils.capitalize(entity)
                + " with " + field + " " + val + " does not exist";
    }
}