Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kevin-cantwell/exceptions
This package is bad and you should feel bad for using it.
https://github.com/kevin-cantwell/exceptions
exceptions fun go golang satire
Last synced: 3 months ago
JSON representation
This package is bad and you should feel bad for using it.
- Host: GitHub
- URL: https://github.com/kevin-cantwell/exceptions
- Owner: kevin-cantwell
- Created: 2017-05-03T03:09:35.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-02-27T16:20:44.000Z (over 1 year ago)
- Last Synced: 2024-06-20T14:26:29.679Z (5 months ago)
- Topics: exceptions, fun, go, golang, satire
- Language: Go
- Homepage:
- Size: 20.5 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-programming-humor - exceptions - Exceptions for Go! (GitHub Projects)
README
This package is bad and you shouldn't use it.
Seriously, don't even read this.
Turn back now.
Still here? Ok cool.
Package `exceptions` brings the old try/catch/finally pattern you know and love to Go. It's a complete abomination of everything that is holy about Go and if you use it your peers will mock you and your friends will abandon you. Here's how it works:
https://github.com/kevin-cantwell/exceptions/blob/e981e831ad71acb2ef102cda772d983e5dbd2bd6/_examples/gofishing/main.go#L10-L26
The above program outputs:
```
Trying to fish...
I caught a Shark!
Stopped fishing.
```https://github.com/kevin-cantwell/exceptions/blob/e981e831ad71acb2ef102cda772d983e5dbd2bd6/_examples/runtime_error/main.go#L10-L20
The above program outputs:
```
caught: runtime error: index out of range [2] with length 0
This will print after catching the error.
```https://github.com/kevin-cantwell/exceptions/blob/28e7d3e02e0e5c0daba6709607616958cb1c94a0/_examples/nilpanic/main.go#L10-L19
The above program outputs:
```
nil panic!
This will print after catching the error.
```This follows the semantics of try...catch...finally where any (optional) `Finally` funcs are invoked directly after `Try` any `Catch` that was invoked. The `Catch` functions take a single arguments: a "cause" of any type. The cause is any type you might expect to be recovered from a panic. Only the first catch that meets these requirements is invoked.
Ironically, this package declares no exception types.
Requires go version 1.18 or greater (for generics)