Created
July 24, 2018 02:25
-
-
Save bhelyer/e5ad5a6abdae6048a8dad93baf9c0e25 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| module main; | |
| import core.exception : Exception; | |
| class OurException : Exception { | |
| val: i32; | |
| this(val: i32) { | |
| this.val = val; | |
| super(new "error code: ${val}"); | |
| } | |
| } | |
| extern (C): | |
| fn throwFunc() { | |
| throw new OurException(4); | |
| } | |
| fn catchFunc() i32 { | |
| try { | |
| throwFunc(); | |
| } catch (oe: OurException) { | |
| return oe.val; | |
| } | |
| return -1; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment