Simplest way to throw an error/exception with a custom message in Swift 2?

前端 未结 10 1857
走了就别回头了
走了就别回头了 2020-12-22 15:57

I want to do something in Swift 2 that I\'m used to doing in multiple other languages: throw a runtime exception with a custom message. For example (in Java):



        
10条回答
  •  既然无缘
    2020-12-22 16:50

    In case you don't need to catch the error and you want to immediately stop the application you can use a fatalError: fatalError ("Custom message here")

提交回复
热议问题