Skip to content

Commit 03302c9

Browse files
feat: Updated sdks/ts/src/utils/invariant.ts (#237)
Co-authored-by: sweep-ai[bot] <128439645+sweep-ai[bot]@users.noreply.github.com>
1 parent a773539 commit 03302c9

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

sdks/ts/src/utils/invariant.ts

+6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1+
/**
2+
* Ensures that a condition is met, throwing a custom error message if not.
3+
* @param condition The condition to test. If falsy, an error is thrown.
4+
* @param message Optional. The error message to throw if the condition is not met. Defaults to "Invariant Violation".
5+
*/
16
export function invariant(
27
condition: any,
38
message: string = "Invariant Violation",
49
): void {
10+
// Throw an error with the provided message if the condition is falsy
511
if (!condition) {
612
throw new Error(message);
713
}

0 commit comments

Comments
 (0)