aboutsummaryrefslogtreecommitdiff
path: root/Timeline/ClientApp/src/app/utilities/language-untilities.ts
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2019-03-11 21:21:02 +0800
committercrupest <crupest@outlook.com>2019-03-11 21:21:02 +0800
commit87f7b00f9414b7633a080838a725a687461efd68 (patch)
treed9d2ea66bb3b5586b3e0f9ac390dc3ac96096e2e /Timeline/ClientApp/src/app/utilities/language-untilities.ts
parent4f7eba96dfdcd831c7a40dee035b8871df8d452b (diff)
downloadtimeline-87f7b00f9414b7633a080838a725a687461efd68.tar.gz
timeline-87f7b00f9414b7633a080838a725a687461efd68.tar.bz2
timeline-87f7b00f9414b7633a080838a725a687461efd68.zip
Fix some compile bugs.
Diffstat (limited to 'Timeline/ClientApp/src/app/utilities/language-untilities.ts')
-rw-r--r--Timeline/ClientApp/src/app/utilities/language-untilities.ts9
1 files changed, 6 insertions, 3 deletions
diff --git a/Timeline/ClientApp/src/app/utilities/language-untilities.ts b/Timeline/ClientApp/src/app/utilities/language-untilities.ts
index f898039a..be9df2dc 100644
--- a/Timeline/ClientApp/src/app/utilities/language-untilities.ts
+++ b/Timeline/ClientApp/src/app/utilities/language-untilities.ts
@@ -2,8 +2,11 @@ export function nullIfUndefined<T>(value: T | undefined): T | null {
return value === undefined ? null : value;
}
-export function throwIfFalsy(value: any, name: string = '<unknown name>') {
- if (!value) {
- throw new Error(name + ' is falsy.');
+export function throwIfNullOrUndefined<T>(value: T | null | undefined,
+ lazyMessage: () => string = () => 'Value mustn\'t be falsy'): T | never {
+ if (value === null || value === undefined) {
+ throw new Error(lazyMessage());
+ } else {
+ return value;
}
}