unierror.uts 1.4 KB
Newer Older
DCloud-yyl's avatar
DCloud-yyl 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
import { LocationErrorCode, IGetLocationFail } from "./interface.uts"

/**
 * 错误主题
 */
export const UniErrorSubject = 'uni-location';
/**
 * 错误码
 * @UniError
 */
export const UniErrors : Map<LocationErrorCode, string> = new Map([

	/**
	 * 缺失权限
	 */
	[1505004, 'maybe not obtain GPS Permission.'],
	/**
	 * iOS特有的缺失高精度权限
	 */
	[1505004, 'Unauthorized access to high-accuracy location services.'],
	/**
	 * 超时
	 */
	[1505021, 'location fail: timeout'],
	/**
	 * 不支持的定位类型
	 */
	[1505022, 'system location support wgs84 only.'],
	/**
	 * 不支持逆地理编码
	 */
	[1505023, 'system location not support geocode.'],
	/**
	 * 没有找到具体的定位引擎,请定位开关是否已打开
	 */
	[1505024, 'Provider is not find,Please ensure that the device location function is turned on'],
	/**
	 * 逆地理编码捕获失败
	 */
	[1505025, 'The system failed to retrieve geocode for the location.'],
	/**
	 * 定位捕获失败
	 */
	[1505026, 'location fail: request error'],
	
]);


export function getErrcode(errCode : number) : LocationErrorCode {
	const res = UniErrors[errCode];
	return res == null ? 1505021 : errCode;
}


export class GetLocationFailImpl extends UniError implements IGetLocationFail {
	constructor(errCode : LocationErrorCode) {
		super();
		this.errSubject = UniErrorSubject;
		this.errCode = errCode;
		this.errMsg = UniErrors[errCode] ?? "";
	}
}