unierror.uts 1.7 KB
Newer Older
DCloud-yyl's avatar
DCloud-yyl 已提交
1 2
import { IMediaError, MediaErrorCode } from "./interface.uts";

3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/**
 * 错误主题
 */
export const UniError_PreviewImage = 'uni-previewImage';
export const UniError_GetImageInfo = "uni-getImageInfo"
export const UniError_SaveImageToPhotosAlbum = "uni-saveImageToPhotosAlbum"
export const UniError_SaveVideoToPhotosAlbum = "uni-saveVideoToPhotosAlbum"
export const UniError_ChooseImage = "uni-chooseImage"
export const UniError_ChooseVideo = "uni-chooseVideo"
export const UniError_CompressImage = "uni-compressImage"
export const UniError_CompressVideo = "uni-compressVideo"
export const UniError_GetVideoInfo = "uni-getVideoInfo"
/**
 * 错误码
 * @UniError
 */
DCloud-yyl's avatar
DCloud-yyl 已提交
19
export const MediaUniErrors : Map<number, string> = new Map([
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
	/**
	 * 用户取消
	 */
	[1101001, 'user cancel'],
	/**
	 * urls至少包含一张图片地址
	 */
	[1101002, 'fail parameter error: parameter.urls should have at least 1 item'],
	/**
	 * 文件不存在
	 */
	[1101003, "file not find"],
	/**
	 * 图片加载失败
	 */
	[1101004, "Failed to load resource"],
	/**
	 * 未获取权限
	 */
	[1101005, "No Permission"],
	/**
	 * 保存异常
	 */
	[1101006, "save error"],
	/**
	 * 图片裁剪失败
	 */
	[1101007, "crop error"],
	/**
	 * 拍照或录像失败
	 */
	[1101008, 'camera error'],
	/**
	 * 图片压缩失败
	 */
	[1101009, "image output failed"],
	/**
	 * 其他错误
	 */
	[1101010, "unexpect error:"]
DCloud-yyl's avatar
DCloud-yyl 已提交
60 61 62 63 64 65 66 67 68 69 70 71 72
]);

export class MediaErrorImpl extends UniError implements IMediaError {
	// #ifdef APP-ANDROID
	override errCode : MediaErrorCode
	// #endif
	constructor(errCode : MediaErrorCode, uniErrorSubject : string) {
		super()
		this.errSubject = uniErrorSubject
		this.errCode = errCode
		this.errMsg = MediaUniErrors[errCode] ?? "";
	}
}