Throws the typed exception for a native result code, or returns normally if it is NativeErrorCode.OK.