eclipse eclipse - 1 year ago 319
Swift Question

Swift convert NSError to String

Is there a way to convert an error of type NSError in swift to a string?

For example for something like this:

do {
try response.status(.OK).send(fileName: "html/index.html")
} catch {

.send() expects a string by default.

Answer Source

If your error is of type NSError, you can use error.localizedDescription to get the string.