Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | 15x 15x 15x 15x 41x 39x 39x 39x 7x 2x 5x 1x 4x 3x 1x 3x 15x 5x | import { messageCheck } from "@jonloucks/contracts-ts/auxiliary/Checks"
import { isNotPresent } from "@jonloucks/contracts-ts/api/Types";
import { used } from "../auxiliary/Checks";
/**
* Runtime exception thrown for Concurrency related problems.
*/
export class ConcurrencyException extends Error {
/**
* Passthrough for {@link Error(String, Throwable)}
*
* @param message the message for this exception
* @param thrown the cause of this exception, null is allowed
*/
public constructor(message: string, thrown: Error | null = null) {
// super(messageCheck(message), thrown || undefined);
super(messageCheck(message));
used(thrown);
this.name = "ConcurrencyException";
Object.setPrototypeOf(this, ConcurrencyException.prototype)
}
/**
* Ensure something that was caught is rethrown as a ConcurrencyException
* @param caught the caught value
* @param message the optional message to use if caught is not an ConcurrencyException
*/
static rethrow(caught: unknown, message?: string): never {
if (isNotPresent(caught)) {
this.throwUnknown(message);
} else if (guard(caught)) {
throw caught;
} else if (caught instanceof Error) {
throw new ConcurrencyException(message ?? caught.message, caught);
} else {
this.throwUnknown(message);
}
}
private static throwUnknown( message?: string): never {
throw new ConcurrencyException(message ?? "Unknown type of caught value.");
}
}
/**
* Determine if an instance is a ConcurrencyException
*
* @param instance the instance to check
* @returns true if the instance is a ConcurrencyException
*/
export function guard(instance: unknown): instance is ConcurrencyException {
return instance instanceof ConcurrencyException;
}
|