S
Sam Roberts
I'm wrapping a library, it returns its errors as numbers (many of them,
too many to wrap even automatically), and I don't know how to raise
exceptions.
I've looked at how ruby deals with unix error numbers. I guess I
could cut-n-paste all the code to that my extension does the same... but
that seems wrong, somehow.
What I'd really like to do is have only one error class, but raise
objects as exceptions, with the objects @errno set to the value,
I'd do this in ruby like this:
class MyErr < StandardError
attr_reader :eno
def initialize(eno); @eno = eno; end
end
...
raise MyError.new(35)
Looking at the exception raising APIs in README.EXT, I can't quite see
how to do this.
Does anybody have any suggestions?
Thanks a lot,
Sam
too many to wrap even automatically), and I don't know how to raise
exceptions.
I've looked at how ruby deals with unix error numbers. I guess I
could cut-n-paste all the code to that my extension does the same... but
that seems wrong, somehow.
What I'd really like to do is have only one error class, but raise
objects as exceptions, with the objects @errno set to the value,
I'd do this in ruby like this:
class MyErr < StandardError
attr_reader :eno
def initialize(eno); @eno = eno; end
end
...
raise MyError.new(35)
Looking at the exception raising APIs in README.EXT, I can't quite see
how to do this.
Does anybody have any suggestions?
Thanks a lot,
Sam