Last active
January 18, 2020 17:21
-
-
Save vicyap/5360540c7ff2805abe8da7ee416156bd to your computer and use it in GitHub Desktop.
catch-all-python-go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
func main() { | |
defer func() { | |
if p := recover(); p != nil { | |
fmt.Printf("%v\n", p) | |
} | |
}() | |
panic("PANIC!") | |
} | |
// $ ./main | |
// PANIC! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def main(): | |
try: | |
raise Exception("PANIC!") | |
except Exception as e: | |
print(e) | |
if __name__ == "__main__": | |
main() | |
# $ python main.py | |
# PANIC! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment