Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New type to return FailureName as list #6

Open
hubts opened this issue Jul 9, 2024 · 0 comments
Open

New type to return FailureName as list #6

hubts opened this issue Jul 9, 2024 · 0 comments

Comments

@hubts
Copy link
Owner

hubts commented Jul 9, 2024

📸 What is this issue?

What is an issue? Please explain with some screenshots.

I tried to apply T | E return type for intermediate functions, such as Service, Repository, and Domain. T means a type of success result, otherwise, E means a type of failure(expected error) result.

In this case, just returning of FailureName to set failure cases makes the ambiguity of returning type for failures.

If we apply a new type to pick FailureName as the list of FailureName, we can specify the returning failure types.

✨ Expected Results

What result do you expect?

For example, define UserService.getUserById(id: string). The function getUserById finds the user by input ID.

If a user is not found, it occurs USER_NOT_FOUND failure, and returns USER_NOT_FOUND as the type FailureName.

However, the use side of function cannot know what failure will be returned, the function can know only that the return type is FailureName. Therefore, defining more specific type definition and detailed failure handling by the definition should be achieved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant