分离部分工具函数

This commit is contained in:
Harvey Zack committed 2018-11-23 09:45:36 +08:00
1 parent d6e35781ca
commit 748ce304e6
15 files changed
+244 -417

No files matched your search

+16
View File
@@ -0,0 +1,16 @@
export class ArtPlayerError extends Error {
constructor(message, context) {
super(message);
if (typeof Error.captureStackTrace === 'function') {
Error.captureStackTrace(this, context || this.constructor);
}
this.name = 'ArtPlayerError';
}
}
export function errorHandle(condition, msg) {
const isFun = typeof condition === 'function';
if (isFun ? !isFun() : !condition) {
throw new ArtPlayerError(msg);
}
}