문제

If I have a function returning an Either such as GetUserFromDb(int id) and the database is offline should I catch the error in the function and wrap it in a failure / Left case or should I let it bubble out as an exception as there is nothing I can do and it really is an exceptional situation.

Comments / Suggestions welcome.

Cheers,

Blair

올바른 솔루션이 없습니다

다른 팁

Wrap the error in the left case. Then you need to handle it explicitly. You can "bubble out" the left case to the point where you want to handle the error, for example with an error message or log entry. I guess you don't want to crash your app if the database is offline but shut it down gracefully and inform some user about the error.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top