> For the complete documentation index, see [llms.txt](https://ankang.gitbook.io/commons/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ankang.gitbook.io/commons/commons-beans/gong-neng/yi-chang-chu-li.md).

# 异常处理

在对象属性拷贝过程中，可能会出现各种异常（如：类型转换异常、日期解析异常等），`BeanUtils`统一抛出`BeanPropertyCopyException`，用户根据需要使用即可。

```java
class Foo {
    Date date;
}
class FooDto {
    @Mapping(datePattern="yyyy-MM-dd")
    String date = "2018-10";
}

try {
    Foo foo = BeanUtils.copyProperties(new FooDto(), Foo.class);
} catch (BeanPropertyCopyException e) {
    System.out.println(e.getMessage()) // "属性：date拷贝时发生异常"
    System.out.println(e.getPropertyName()) // "date"
    System.out.println(e.getSourceObject()) // FooDto(date=2018-10)
}
```
