mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
feat: Use asynchandler library for handlers
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { AsyncHandler } from '../../src/util/handlers/AsyncHandler';
|
||||
import { AsyncHandler } from 'asynchronous-handlers';
|
||||
|
||||
export class StaticAsyncHandler<TOut> extends AsyncHandler<any, TOut> {
|
||||
private readonly canHandleStatic: boolean;
|
||||
|
||||
@@ -105,6 +105,19 @@ export function compareMaps<TKey, TVal>(map1: Map<TKey, TVal>, map2: Map<TKey, T
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the error thrown by the given function.
|
||||
* Throws an error if the function does not throw.
|
||||
*/
|
||||
export async function getError(fn: () => any): Promise<Error> {
|
||||
try {
|
||||
await fn();
|
||||
} catch (err: unknown) {
|
||||
return err as Error;
|
||||
}
|
||||
throw new Error('Function did not throw');
|
||||
}
|
||||
|
||||
/**
|
||||
* Mocks (some) functions of the fs system library.
|
||||
* It is important that you call `jest.mock('node:fs');` in your test file before calling this!!!
|
||||
|
||||
Reference in New Issue
Block a user