-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[REFACTOR] Change error result data structure
Squashed commit of the following: commit 8eb65e0a3abb4b38115e48a43f95a78ef9f83240 Author: Luke Autry <[email protected]> Date: Tue Nov 26 15:35:22 2019 -0500 new error data structure
- Loading branch information
Showing
52 changed files
with
763 additions
and
1,067 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
import { Result } from "./result"; | ||
import { success } from "./success"; | ||
import { error } from "./error"; | ||
|
||
export const isBoolean = (value: unknown): value is boolean => | ||
typeof value === "boolean"; | ||
|
||
export const assertBoolean = (value: unknown): Result<boolean> => | ||
isBoolean(value) ? success(value) : error("single", { value: "boolean" }); | ||
isBoolean(value) ? success(value) : { kind: "single", value: "boolean" }; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
import { Result } from "./result"; | ||
import { success } from "./success"; | ||
import { error } from "./error"; | ||
|
||
export const isFalse = (value: unknown): value is false => value === false; | ||
|
||
export const assertFalse = (value: unknown): Result<false> => | ||
isFalse(value) ? success(value) : error("single", { value: false }); | ||
isFalse(value) ? success(value) : { kind: "single", value: false }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
import { Result } from "./result"; | ||
import { success } from "./success"; | ||
import { error } from "./error"; | ||
|
||
export const isNull = (value: unknown): value is null => value === null; | ||
|
||
export const assertNull = (value: unknown): Result<null> => | ||
isNull(value) ? success(value) : error("single", { value: null }); | ||
isNull(value) ? success(value) : { kind: "single", value: null }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
import { Result } from "./result"; | ||
import { success } from "./success"; | ||
import { error } from "./error"; | ||
|
||
export const isNumber = (value: unknown): value is number => | ||
typeof value === "number"; | ||
|
||
export const assertNumber = (value: unknown): Result<number> => | ||
isNumber(value) ? success(value) : error("single", { value: "number" }); | ||
isNumber(value) ? success(value) : { kind: "single", value: "number" }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
import { Result } from "./result"; | ||
import { success } from "./success"; | ||
import { error } from "./error"; | ||
|
||
export const isString = (value: unknown): value is string => | ||
typeof value === "string"; | ||
|
||
export const assertString = (value: unknown): Result<string> => | ||
isString(value) ? success(value) : error("single", { value: "string" }); | ||
isString(value) ? success(value) : { kind: "single", value: "string" }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { ISuccessResult } from "./result"; | ||
|
||
export const success = <T>(value: T): ISuccessResult<T> => ({ | ||
success: true, | ||
kind: "success", | ||
value | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
import { Result } from "./result"; | ||
import { success } from "./success"; | ||
import { error } from "./error"; | ||
|
||
export const isTrue = (value: unknown): value is true => value === true; | ||
|
||
export const assertTrue = (value: unknown): Result<true> => | ||
isTrue(value) ? success(value) : error("single", { value: true }); | ||
isTrue(value) ? success(value) : { kind: "single", value: true }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
import { Result } from "./result"; | ||
import { success } from "./success"; | ||
import { error } from "./error"; | ||
|
||
export const isUndefined = (value: unknown): value is undefined => | ||
typeof value === "undefined"; | ||
|
||
export const assertUndefined = (value: unknown): Result<undefined> => | ||
isUndefined(value) ? success(value) : error("single", { value: "undefined" }); | ||
isUndefined(value) ? success(value) : { kind: "single", value: "undefined" }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.