@artus/core
Advanced tools
Comparing version 1.0.0-beta.30 to 1.0.0-beta.31
import 'reflect-metadata'; | ||
import { Container } from '@artus/injection'; | ||
import { ArtusStdError, ExceptionHandler } from './exception'; | ||
import { ArtusStdError } from './exception'; | ||
import { HookFunction, LifecycleManager } from './lifecycle'; | ||
@@ -18,3 +18,2 @@ import { LoaderFactory, Manifest } from './loader'; | ||
get packages(): Record<string, any>; | ||
get exceptionHandler(): ExceptionHandler; | ||
get configurationHandler(): ConfigurationHandler; | ||
@@ -21,0 +20,0 @@ get logger(): LoggerType; |
@@ -34,5 +34,2 @@ "use strict"; | ||
} | ||
get exceptionHandler() { | ||
return this.container.get(exception_1.ExceptionHandler); | ||
} | ||
get configurationHandler() { | ||
@@ -52,3 +49,2 @@ return this.container.get(configuration_1.default); | ||
this.container.set({ type: trigger_1.default }); | ||
this.container.set({ type: exception_1.ExceptionHandler }); | ||
} | ||
@@ -81,6 +77,6 @@ async load(manifest, root = process.cwd()) { | ||
throwException(code) { | ||
this.exceptionHandler.throw(code); | ||
throw new exception_1.ArtusStdError(code); | ||
} | ||
createException(code) { | ||
return this.exceptionHandler.create(code); | ||
return new exception_1.ArtusStdError(code); | ||
} | ||
@@ -87,0 +83,0 @@ addLoaderListener() { |
@@ -1,3 +0,5 @@ | ||
import ExceptionHandler from './handler'; | ||
export * from './error'; | ||
export { ExceptionHandler, }; | ||
export * from './constant'; | ||
export * from './decorator'; | ||
export * from './impl'; | ||
export * from './types'; | ||
export * from './utils'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ExceptionHandler = void 0; | ||
const tslib_1 = require("tslib"); | ||
const handler_1 = tslib_1.__importDefault(require("./handler")); | ||
exports.ExceptionHandler = handler_1.default; | ||
tslib_1.__exportStar(require("./error"), exports); | ||
tslib_1.__exportStar(require("./constant"), exports); | ||
tslib_1.__exportStar(require("./decorator"), exports); | ||
tslib_1.__exportStar(require("./impl"), exports); | ||
tslib_1.__exportStar(require("./types"), exports); | ||
tslib_1.__exportStar(require("./utils"), exports); |
@@ -0,1 +1,3 @@ | ||
import { Constructable } from '@artus/injection'; | ||
import { ArtusStdError } from './impl'; | ||
export interface ExceptionItem { | ||
@@ -5,1 +7,6 @@ desc: string | Record<string, string>; | ||
} | ||
export declare type ExceptionIdentifier = string | symbol | Constructable<Error>; | ||
export declare type ExceptionFilterMapType = Map<ExceptionIdentifier, Constructable<ExceptionFilterType>>; | ||
export interface ExceptionFilterType { | ||
catch(err: Error | ArtusStdError): void | Promise<void>; | ||
} |
import { ManifestItem, Loader, LoaderFindOptions } from '../types'; | ||
import { ExceptionItem } from '../../exception/types'; | ||
declare class ExceptionLoader implements Loader { | ||
private container; | ||
constructor(container: any); | ||
static is(opts: LoaderFindOptions): Promise<boolean>; | ||
@@ -7,0 +5,0 @@ load(item: ManifestItem): Promise<Record<string, ExceptionItem>>; |
@@ -5,10 +5,7 @@ "use strict"; | ||
const decorator_1 = require("../decorator"); | ||
const exception_1 = require("../../exception"); | ||
const load_meta_file_1 = require("../../utils/load_meta_file"); | ||
const constant_1 = require("../../constant"); | ||
const utils_1 = require("../../utils"); | ||
const exception_1 = require("../../exception"); | ||
let ExceptionLoader = class ExceptionLoader { | ||
constructor(container) { | ||
this.container = container; | ||
} | ||
static async is(opts) { | ||
@@ -18,7 +15,6 @@ return (0, utils_1.isMatch)(opts.filename, constant_1.EXCEPTION_FILENAME); | ||
async load(item) { | ||
const exceptionHandler = this.container.get(exception_1.ExceptionHandler); | ||
try { | ||
const codeMap = await (0, load_meta_file_1.loadMetaFile)(item.path); | ||
for (const [errCode, exceptionItem] of Object.entries(codeMap)) { | ||
exceptionHandler.registerCode(errCode, exceptionItem); | ||
exception_1.ArtusStdError.registerCode(errCode, exceptionItem); | ||
} | ||
@@ -34,5 +30,4 @@ return codeMap; | ||
ExceptionLoader = tslib_1.__decorate([ | ||
(0, decorator_1.DefineLoader)('exception'), | ||
tslib_1.__metadata("design:paramtypes", [Object]) | ||
(0, decorator_1.DefineLoader)('exception') | ||
], ExceptionLoader); | ||
exports.default = ExceptionLoader; |
import ModuleLoader from './module'; | ||
import ConfigLoader from './config'; | ||
import ExceptionLoader from './exception'; | ||
import ExceptionFilterLoader from './exception_filter'; | ||
import LifecycleLoader from './lifecycle'; | ||
@@ -9,2 +10,2 @@ import PluginMetaLoader from './plugin_meta'; | ||
import PackageLoader from './package'; | ||
export { ModuleLoader, ConfigLoader, ExceptionLoader, LifecycleLoader, PluginMetaLoader, PluginConfigLoader, FrameworkConfigLoader, PackageLoader, }; | ||
export { ModuleLoader, ConfigLoader, ExceptionLoader, ExceptionFilterLoader, LifecycleLoader, PluginMetaLoader, PluginConfigLoader, FrameworkConfigLoader, PackageLoader, }; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.PackageLoader = exports.FrameworkConfigLoader = exports.PluginConfigLoader = exports.PluginMetaLoader = exports.LifecycleLoader = exports.ExceptionLoader = exports.ConfigLoader = exports.ModuleLoader = void 0; | ||
exports.PackageLoader = exports.FrameworkConfigLoader = exports.PluginConfigLoader = exports.PluginMetaLoader = exports.LifecycleLoader = exports.ExceptionFilterLoader = exports.ExceptionLoader = exports.ConfigLoader = exports.ModuleLoader = void 0; | ||
const tslib_1 = require("tslib"); | ||
@@ -11,2 +11,4 @@ const module_1 = tslib_1.__importDefault(require("./module")); | ||
exports.ExceptionLoader = exception_1.default; | ||
const exception_filter_1 = tslib_1.__importDefault(require("./exception_filter")); | ||
exports.ExceptionFilterLoader = exception_filter_1.default; | ||
const lifecycle_1 = tslib_1.__importDefault(require("./lifecycle")); | ||
@@ -13,0 +15,0 @@ exports.LifecycleLoader = lifecycle_1.default; |
@@ -1,5 +0,5 @@ | ||
import { Constructable } from '@artus/injection'; | ||
import { Constructable, Container } from '@artus/injection'; | ||
import { ManifestItem, Loader } from '../types'; | ||
declare class ModuleLoader implements Loader { | ||
private container; | ||
protected container: Container; | ||
constructor(container: any); | ||
@@ -6,0 +6,0 @@ load(item: ManifestItem): Promise<Constructable[]>; |
@@ -7,5 +7,7 @@ "use strict"; | ||
const constant_1 = require("../constant"); | ||
const exception_1 = require("../exception"); | ||
let Trigger = class Trigger { | ||
constructor() { | ||
this.pipeline = new pipeline_1.Pipeline(); | ||
this.pipeline.use(exception_1.exceptionFilterMiddleware); | ||
} | ||
@@ -12,0 +14,0 @@ async use(middleware) { |
{ | ||
"name": "@artus/core", | ||
"version": "1.0.0-beta.30", | ||
"version": "1.0.0-beta.31", | ||
"description": "Core package of Artus", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
107549
113
2582