Skip to content

Instantly share code, notes, and snippets.

@bhelyer
Created July 24, 2018 02:25
Show Gist options
  • Select an option

  • Save bhelyer/e5ad5a6abdae6048a8dad93baf9c0e25 to your computer and use it in GitHub Desktop.

Select an option

Save bhelyer/e5ad5a6abdae6048a8dad93baf9c0e25 to your computer and use it in GitHub Desktop.
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