mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: fix things with stupid esbuild
This commit is contained in:
3 files changed
+28
-20
No files matched your search
@@ -5,25 +5,6 @@ interface IHydroError {
|
||||
new(...args: any[]): HydroError
|
||||
}
|
||||
|
||||
const Err = (name: string, Class: IHydroError, ...info: Array<(() => string) | string | number>) => {
|
||||
let msg: () => string;
|
||||
let code: number;
|
||||
for (const item of info) {
|
||||
if (typeof item === 'number') {
|
||||
code = item;
|
||||
} else if (typeof item === 'string') {
|
||||
msg = function () { return item; };
|
||||
} else if (typeof item === 'function') {
|
||||
msg = item;
|
||||
}
|
||||
}
|
||||
const HydroError = class extends Class { };
|
||||
HydroError.prototype.name = name;
|
||||
if (msg) HydroError.prototype.msg = msg;
|
||||
if (code) HydroError.prototype.code = code;
|
||||
return HydroError;
|
||||
};
|
||||
|
||||
export class HydroError extends Error {
|
||||
params: any[];
|
||||
code: number;
|
||||
@@ -42,6 +23,29 @@ export class HydroError extends Error {
|
||||
}
|
||||
}
|
||||
|
||||
const Err = (name: string, Class: IHydroError, ...info: Array<(() => string) | string | number>) => {
|
||||
let msg: () => string;
|
||||
let code: number;
|
||||
for (const item of info) {
|
||||
if (typeof item === 'number') {
|
||||
code = item;
|
||||
} else if (typeof item === 'string') {
|
||||
msg = function () { return item; };
|
||||
} else if (typeof item === 'function') {
|
||||
msg = item;
|
||||
}
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-shadow
|
||||
return class HydroError extends Class {
|
||||
name = name;
|
||||
constructor(...args: any[]) {
|
||||
super(...args);
|
||||
if (msg) this.msg = msg;
|
||||
if (code) this.code = code;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const UserFacingError = Err('UserFacingError', HydroError, 'UserFacingError', 400);
|
||||
export const SystemError = Err('SystemError', HydroError, 'SystemError', 500);
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ class TaskModel {
|
||||
|
||||
static getFirst = getFirst;
|
||||
|
||||
static async consume(query: any, cb: Function, destoryOnError = true) {
|
||||
static consume(query: any, cb: Function, destoryOnError = true) {
|
||||
return new Consumer(query, cb, destoryOnError);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,10 @@ function transform(filename) {
|
||||
});
|
||||
if (result.warnings.length) console.warn(result.warnings);
|
||||
map[filename] = result.map;
|
||||
if (process.env.LOADER_DUMP_CODE && filename.endsWith(`/${process.env.LOADER_DUMP_CODE}`)) {
|
||||
console.log(`-----${filename}-----`);
|
||||
console.log(result.code.split('/# sourceMappingURL=')[0]);
|
||||
}
|
||||
return result.code;
|
||||
}
|
||||
const _script = new vm.Script('"Hydro"', { produceCachedData: true });
|
||||
|
||||
Reference in new issue
Block a user