# (Solved) Ch 7 Warning: Conditional downcast from 'Error?' to 'NSError'

**URL:** <https://forums.kodeco.com/t/solved-ch-7-warning-conditional-downcast-from-error-to-nserror/29736>\
**Category:** Core Data by Tutorials\
**Created:** [May 16, 2017, 3:52pm UTC](https://forums.kodeco.com/t/solved-ch-7-warning-conditional-downcast-from-error-to-nserror/29736 "2017-05-16T15:52:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![avantjer](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/avantjer/32/81494_2.png) [@avantjer](https://forums.kodeco.com/u/avantjer)\
**Post date:** [May 16, 2017, 3:52pm UTC](https://forums.kodeco.com/t/solved-ch-7-warning-conditional-downcast-from-error-to-nserror/29736/1 "2017-05-16T15:52:39Z")

</div>

There are a couple places in CampgroundManager and CampgroundManagerTests where…

**if let error = error as? NSError…**

…results in the following compiler warning:

**Conditional downcast from ‘Error?’ to ‘NSError’ is a bridging conversion; did you mean to use ‘as’?**

Is there a good way to resolve this?  
Thanks…

Jerry

---

<div class="post-metadata">

**Author:** ![avantjer](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/avantjer/32/81494_2.png) [@avantjer](https://forums.kodeco.com/u/avantjer)\
**Post date:** [May 16, 2017, 5:18pm UTC](https://forums.kodeco.com/t/solved-ch-7-warning-conditional-downcast-from-error-to-nserror/29736/2 "2017-05-16T17:18:14Z")

</div>

Apparently the solution was to change the line to…

**if let error = error as NSError?**

Jerry

---

<div class="post-metadata">

**Author:** ![macish0k](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/macish0k/32/81494_2.png) [@macish0k](https://forums.kodeco.com/u/macish0k)\
**Post date:** [August 10, 2017, 5:12am UTC](https://forums.kodeco.com/t/solved-ch-7-warning-conditional-downcast-from-error-to-nserror/29736/3 "2017-08-10T05:12:47Z")

</div>

Hi, Jerry!  
If you use do-catch swift statement, for catching any errors you should type something like:

```
// Swift 3.1
do {
  try doSomethingWithPossibleErrors()
} catch let error as NSError {
  doSomethingIfErrorAppears()
}

```

, where catch construction expects error-type variable which you can use inside curly braces after catching. For instance, you can print out the error description like below.

```
fatalError("Error: \(error), Description: \(error.userInfo)")

```
