# Chapter 2 - Type 'Result\<String, Error\>' has no member 'error'

**URL:** <https://forums.kodeco.com/t/chapter-2-type-result-string-error-has-no-member-error/158871>\
**Category:** RxSwift\
**Created:** [November 29, 2021, 11:51am UTC](https://forums.kodeco.com/t/chapter-2-type-result-string-error-has-no-member-error/158871 "2021-11-29T11:51:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lmw41](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/lmw41/32/110937_2.png) [@lmw41](https://forums.kodeco.com/u/lmw41)\
**Post date:** [November 29, 2021, 11:51am UTC](https://forums.kodeco.com/t/chapter-2-type-result-string-error-has-no-member-error/158871/1 "2021-11-29T11:51:10Z")

</div>

I got the error when using single, like the code below.

guard let path = Bundle.main.path(forResource: name, ofType: “txt”) else {  
single(.error(FileReadError.fileNotFound))  
return disposable  
}

The error message from compiler is → Type ‘Result\<String, Error\>’ has no member ‘error’

Can somebody tell me how to solve this problem?

---

<div class="post-metadata">

**Author:** ![shogunkaramazov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/shogunkaramazov/32/108826_2.png) [@shogunkaramazov](https://forums.kodeco.com/u/shogunkaramazov)\
**Post date:** [December 9, 2021, 3:50pm UTC](https://forums.kodeco.com/t/chapter-2-type-result-string-error-has-no-member-error/158871/2 "2021-12-09T15:50:01Z")

</div>

@lmw41 The `Single<String>` trait works with the `Result<String, Error>` enumeration under the hood, so you should use the `Result<String, Error>.failure(Error)` enumeration case instead of the `SingleEvent<String>.error(Error)` one to return errors from `Single<String>` traits in this case like this:

```auto
guard let path = Bundle.main.path(forResource: name, ofType: “txt”) else {
  single(.failure(FileReadError.fileNotFound))
  return disposable
}

```

You should also use the `Result<String, Error>.failure(Error)` enumeration case instead of the `SingleEvent<String>.error(Error)` one to throw errors from `Single<String>` traits in your code as follows:

```auto
loadText(from: "Copyright")
  .subscribe {
     switch $0 {
       case .success(let string):
         print(string)
       case .failure(let error):
         print(error)
     }
   }
  .disposed(by: disposeBag)

```

We will definitely fix this in the next edition of the book. Thank you!

---

<div class="post-metadata">

**Author:** ![24395.carlos](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/24395.carlos/32/105896_2.png) [@24395.carlos](https://forums.kodeco.com/u/24395.carlos)\
**Post date:** [May 2, 2022, 11:58am UTC](https://forums.kodeco.com/t/chapter-2-type-result-string-error-has-no-member-error/158871/3 "2022-05-02T11:58:10Z")

</div>

Hello. This error is still in the book. Thanks for the reply. You helped me.

---

<div class="post-metadata">

**Author:** ![system](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@system](https://forums.kodeco.com/u/system)\
**Post date:** [May 15, 2022, 3:51am UTC](https://forums.kodeco.com/t/chapter-2-type-result-string-error-has-no-member-error/158871/4 "2022-05-15T03:51:37Z")

</div>

This topic was automatically closed after 166 days. New replies are no longer allowed.
