paascloud/paascloud-master · error · MdcBizException
MDC10021002
MDC10021002
Error message
MDC10021002
What it means
MDC10021002 in OpcRpcServiceImpl.getLocationById is thrown when the Wrapper returned by opcGaodeFeignApi.getLocationByIpAddr reports an error (wrapper.error() true). It indicates the remote gaode ip-location call failed at the business level even though a Wrapper was returned.
Solutions
- Read the Wrapper's error message/code to find the upstream cause
- Verify the IP format passed in addressId is valid
- Check AMap API key validity and quotas on the opc side
- Add a fallback location for failed lookups
Example fix
// before
if (wrapper.error()) {
throw new MdcBizException(ErrorCodeEnum.MDC10021002);
}
// after
if (wrapper.error()) {
logger.warn("gaode lookup failed: {}", wrapper.getMessage());
return GlobalConstant.DEFAULT_LOCATION;
} Defensive patterns
Strategy: try-catch
Validate before calling
if (addressId == null || !addressId.matches("^(\\d{1,3}\\.){3}\\d{1,3}$")) { throw new IllegalArgumentException("invalid ip"); } Type guard
boolean ok = wrapper != null && !wrapper.error() && wrapper.getResult() != null;
Try / catch
try { ... } catch (MdcBizException e) { logger.warn("gaode error: {}", e.getMessage()); return GlobalConstant.DEFAULT_LOCATION; } Prevention
- Validate IP format before calling
- Watch AMap quotas and key expiry
- Cache successful lookups to reduce upstream calls
When it happens
Trigger: getLocationById(addressId) called with an IP/address the remote service rejects, or the opc/gaode service returns an error envelope (invalid IP format, quota exceeded, upstream AMap error).
Common situations: Expired or rate-limited AMap API key; caller passes a malformed IP; opc service wrapping an upstream error into the Wrapper.
Related errors
AI-assisted analysis of paascloud/paascloud-master@781281a950 (2026-09-10).
Data as JSON: /api/errors/9fdbe2c8105c9676.
Report an issue: GitHub.
Appendix: source
Thrown at paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/OpcRpcServiceImpl.java:46
* The class Opc rpc service.
*
* @author paascloud.net @gmail.com
*/
@Slf4j
@Service
public class OpcRpcServiceImpl implements OpcRpcService {
@Resource
private OpcGaodeFeignApi opcGaodeFeignApi;
@Override
public String getLocationById(String addressId) {
try {
Wrapper<GaodeLocation> wrapper = opcGaodeFeignApi.getLocationByIpAddr(addressId);
if (wrapper == null) {
throw new MdcBizException(ErrorCodeEnum.GL99990002);
}
if (wrapper.error()) {
throw new MdcBizException(ErrorCodeEnum.MDC10021002);
}
GaodeLocation result = wrapper.getResult();
assert result != null;
return result.getProvince().contains("市") ? result.getCity() : result.getProvince() + GlobalConstant.Symbol.SHORT_LINE + result.getCity();
} catch (Exception e) {
log.error("getLocationById={}", e.getMessage(), e);
}
return null;
}
}
View on GitHub (pinned to 781281a950)