diff --git a/interop/src/cpp/DeserializerBase.h b/interop/src/cpp/DeserializerBase.h index eb87c410949f66bc863826b69169f18c05d2ccb7..7f62a8768b5b73acca635d776a24f49e0eb08eb2 100644 --- a/interop/src/cpp/DeserializerBase.h +++ b/interop/src/cpp/DeserializerBase.h @@ -52,8 +52,7 @@ inline const char *tagName(InteropTag tag) case InteropTag::INTEROP_TAG_OBJECT: return "OBJECT"; } - fprintf(stderr, "tag name %d is wrong\n", tag); - throw "Error"; + INTEROP_FATAL("Fatal error"); } inline const char *tagNameExact(InteropTag tag) @@ -75,8 +74,7 @@ inline const char *tagNameExact(InteropTag tag) case InteropTag::INTEROP_TAG_OBJECT: return "INTEROP_TAG_OBJECT"; } - fprintf(stderr, "tag name %d is wrong\n", tag); - throw "Error"; + INTEROP_FATAL("Fatal error"); } inline InteropFunction makeArkFunctionFromId(InteropInt32 id) { @@ -464,8 +462,7 @@ public: } else { - fprintf(stderr, "Bad number tag %d\n", result.tag); - throw "Unknown number tag"; + INTEROP_FATAL("Fatal error"); } return result; } @@ -503,8 +500,7 @@ public: } default: { - fprintf(stderr, "Bad length tag %d\n", result.type); - throw "Error"; + INTEROP_FATAL("Fatal error"); } } return result; diff --git a/interop/src/cpp/SerializerBase.h b/interop/src/cpp/SerializerBase.h index 951ccac942f71fb2d48c25e8d90ae52c17fe07d3..8d638146613b76db7f99a404bfd6fd7c87019801 100644 --- a/interop/src/cpp/SerializerBase.h +++ b/interop/src/cpp/SerializerBase.h @@ -172,8 +172,7 @@ public: } else if (value.tag == InteropTag::INTEROP_TAG_FLOAT32) { writeFloat32(value.f32); } else { - fprintf(stderr, "Bad number tag %d\n", value.tag); - throw "Unknown number tag"; + INTEROP_FATAL("Unknown tag number"); } } diff --git a/interop/src/cpp/ets/convertors-ets.cc b/interop/src/cpp/ets/convertors-ets.cc index 455548eeb2457f4a254bc9d30b55186bfa5b2180..d6f66171c61f3c7aac42a83ba8c2eaef3cdecde8 100644 --- a/interop/src/cpp/ets/convertors-ets.cc +++ b/interop/src/cpp/ets/convertors-ets.cc @@ -111,7 +111,6 @@ const std::vector>& EtsExports: auto it = implementations.find(module); if (it == implementations.end()) { LOGE("Module %s is not registered", module.c_str()); - throw "Fatal error"; } return it->second; } @@ -130,7 +129,6 @@ void EtsExports::setClasspath(const char* module, const char *classpath) { classpaths.insert(std::make_pair(module, classpath)); } else { LOGE("Classpath for module %s was redefined", module); - throw "Fatal error"; } } @@ -151,5 +149,4 @@ const std::string& EtsExports::getClasspath(const std::string& module) { return defaultClasspath->second; } LOGE("Classpath for module %s was not registered", module.c_str()); - throw "Fatal error"; } diff --git a/interop/src/cpp/interop-types.h b/interop/src/cpp/interop-types.h index b8aeefb3465d2f0472f39254265831a1ddcd69c4..ff0f53b4f2d4111d9ead0ea5d0b98f1f26936597 100644 --- a/interop/src/cpp/interop-types.h +++ b/interop/src/cpp/interop-types.h @@ -3,6 +3,8 @@ #include +#define INTEROP_FATAL(msg, ...) fprintf(stderr, msg "\n", ##__VA_ARGS__); assert(false); + typedef enum InteropTag { INTEROP_TAG_UNDEFINED = 101, diff --git a/interop/src/cpp/types/signatures.cc b/interop/src/cpp/types/signatures.cc index 3d035719f51673ed3183d266358fa9bc4b0fe31a..9e16aa58666ef540d1ba9b4a8fa3206cf736130a 100644 --- a/interop/src/cpp/types/signatures.cc +++ b/interop/src/cpp/types/signatures.cc @@ -78,7 +78,6 @@ std::string sigType(const std::string &type) { KOALA_INTEROP_TYPEDEFS("sigType", "jni") #endif fprintf(stderr, "Unhandled type: %s\n", type.c_str()); - throw "Error"; } std::string codeType(const std::string &type) { @@ -88,7 +87,6 @@ std::string codeType(const std::string &type) { KOALA_INTEROP_TYPEDEFS("codeType", "jni") #endif fprintf(stderr, "Unhandled type: %s\n", type.c_str()); - throw "Error"; } std::string convertType(const char* name, const char* koalaType) {