Flinging poo in Swift

Thanks to one of the genuine upsides of Swift, full Unicode support in the compiler itself, you can do:

enum EmojiErrors: Error {
    case 💩
}

let 💩 = EmojiErrors.💩

Finally you can express yourself honestly within your program:

throw(💩)

Or, if you prefer to be polite & British about it:

func flinging<E: Error>(_ error: E) throws -> Never {
    throw(error)
}

try flinging(💩)

You can go further, if you like, and have all manner of interesting things thrown about your program:

enum EmojiErrors: Error {
    case 💩
    case 🖕
    case 🐞
    case 🎮
    case 🏈
    case 💣
    case 📱
    case 💻
    case 🖥
    case 🎉
}

Leave a Comment