Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. enum NetworkRequestError: Error {
  2. case hostNotAvailable
  3. case accountNotAvailable
  4.  
  5. func finish<T>() -> Result<T, NetworkRequestError> {
  6. return .failure(self)
  7. }
  8. }
  9.  
  10. func fetch(result: @escaping (Result<(any: [Any], any1: [Any]), NetworkRequestError>) -> Void) {
  11. guard host != nil else {
  12. result(NetworkRequestError.hostNotAvailable.finish())
  13. return
  14. }
  15.  
  16. ...
  17. }
  18.  
  19. enum NetworkRequestError: Error {
  20. case hostNotAvailable
  21. case accountNotAvailable
  22. }
  23.  
  24. func fetch(result: @escaping (Result<(any: [Any], any1: [Any]), NetworkRequestError>) -> Void) {
  25. guard host != nil else {
  26. result(.failure(.hostNotAvailable))
  27. return
  28. }
  29.  
  30. ...
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement