Skip to content

Instantly share code, notes, and snippets.

@laevandus
Created September 8, 2023 08:43
Show Gist options
  • Save laevandus/aab9bb58e1215a87407b416922259a7a to your computer and use it in GitHub Desktop.
Save laevandus/aab9bb58e1215a87407b416922259a7a to your computer and use it in GitHub Desktop.
let errorMessages = [
-1: "Failed to read the file"
//…
]
let errorCode = -2
let message = errorMessages[errorCode, default: "Unknown error occured" ]
print(message)
// Unknown error occured
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment