CommunitySolidServer/test/util/StaticAsyncHandler.ts
smessie 99464d9a95
feat: Add logging
* feat: Add logging

* refactor: Configure the logger for the tests once globally

* feat: Add logging

* fix: Fix ESLint errors due to merge conflicts

* Review log and error messages.

* refactor: Cleanup a bit

* refactor: Change to logger info calls

Co-authored-by: Ruben Verborgh <ruben@verborgh.org>
2020-10-26 10:31:01 +01:00

24 lines
603 B
TypeScript

import { AsyncHandler } from '../../src/util/AsyncHandler';
export class StaticAsyncHandler<TOut> extends AsyncHandler<any, TOut> {
private readonly canHandleStatic: boolean;
private readonly handleStatic: TOut;
public constructor(canHandleStatic: boolean, handleStatic: TOut) {
super();
this.canHandleStatic = canHandleStatic;
this.handleStatic = handleStatic;
}
public async canHandle(): Promise<void> {
if (this.canHandleStatic) {
return;
}
throw new Error('Not supported');
}
public async handle(): Promise<TOut> {
return this.handleStatic;
}
}