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
commit9a11e4f5081d6dff7f1587e636f39de4b8983753 (patch)
tree9770d2ac8ce0b856928fcc83cf943b077e63f5c8 /Timeline/ClientApp/src/app/utilities/language-untilities.ts
parent6e8434fa885bdb7ef9fd0f09a8cd29c0e17cef5b (diff)
downloadtimeline-9a11e4f5081d6dff7f1587e636f39de4b8983753.tar.gz
timeline-9a11e4f5081d6dff7f1587e636f39de4b8983753.tar.bz2
timeline-9a11e4f5081d6dff7f1587e636f39de4b8983753.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;
}
}