New file |
| | |
| | | package com.hdl.sdk.link.common.utils; |
| | | |
| | | import com.hdl.sdk.link.HDLLinkLocalSdk; |
| | | import com.hdl.sdk.link.R; |
| | | import com.hdl.sdk.link.common.exception.HDLLinkCode; |
| | | |
| | | import java.util.HashMap; |
| | | |
| | | /** |
| | | * Created by hxb on 2023/4/22. |
| | | */ |
| | | public class ErrorUtils { |
| | | //键:code 值:中英文描述 |
| | | public static final HashMap<String, String> errorsMap = new HashMap<>(); |
| | | |
| | | |
| | | |
| | | /** |
| | | * 通过状态码获取异常对象 |
| | | * @param code 状态码 |
| | | * @return 异常对象 |
| | | */ |
| | | public static HDLLinkCode getByCode(int code) { |
| | | String msg = errorsMap.get(code + ""); |
| | | if (msg == null) { |
| | | msg = "unkown"; |
| | | } |
| | | return new HDLLinkCode(code, msg); |
| | | } |
| | | } |