Error handling refactor

Refactor the error handling to make it compatible with msvc and to make easier for the FFI.

Merge request reports

Loading