문제

I am trying to create an extension to wrap an existing DLL without extensive knowledge of C/++. I have used the sample extension as a base and everything seems to work fine, what I would like to do is have some error handling inside my dll.

Is there a way of sending custom errors back to dart if something inside the dll fails? Would it just be a case of sending lets say an array with the first parameter being a bool as to whether it failed or not and the second parameter being a string for the error if there is one. Or is there an actual way to throw errors from the dll itself?

Hope this made sense, Thanks,

도움이 되었습니까?

해결책

You should take a look inside dart_api.h file, it contains a lot of comments about Dart native stuff.

I have found Dart_ThrowException function there, but also a comment saying that Dart_NewUnhandledExceptionError should be used instead.

Both functions need a Dart exception object handle. It seems that Dart team uses their own Dart Util library to create them:

Dart_ThrowException(DartUtils::NewDartArgumentError("error message"))
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top