Skip to content

Commit b968de5

Browse files
committed
Address review feedback
1 parent 54208c5 commit b968de5

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

libs/common/src/platform/abstractions/sdk/sdk.service.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,27 @@ export class UserNotLoggedInError extends Error {
1212
}
1313
}
1414

15-
// Converts a string to UUID. Will throw an error if the UUID is non valid.
16-
export function uuid<T extends Uuid>(uuid: string): T {
15+
export class InvalidUuid extends Error {
16+
constructor(uuid: string) {
17+
super(`Invalid UUID: ${uuid}`);
18+
}
19+
}
20+
21+
/**
22+
* Converts a string to UUID. Will throw an error if the UUID is non valid.
23+
*/
24+
export function asUuid<T extends Uuid>(uuid: string): T {
1725
if (Utils.isGuid(uuid)) {
1826
return uuid as T;
1927
}
2028

21-
throw new Error(`Invalid UUID: ${uuid}`);
29+
throw new InvalidUuid(uuid);
2230
}
2331

24-
// Converts a UUID to the string representation.
25-
export function uuid_to_string<T extends Uuid>(uuid: T): string {
32+
/**
33+
* Converts a UUID to the string representation.
34+
*/
35+
export function uuidToString<T extends Uuid>(uuid: T): string {
2636
return uuid as unknown as string;
2737
}
2838

0 commit comments

Comments
 (0)