Add catch-all error handler to native image functions

This commit is contained in:
TheEssem 2021-05-03 16:01:48 -05:00
parent e5d9388952
commit 6a96686772
34 changed files with 136 additions and 0 deletions

View File

@ -49,7 +49,11 @@ Napi::Value Blur(const Napi::CallbackInfo &info) {
blob.length()));
result.Set("type", type);
return result;
} catch (Napi::Error const &err) {
throw err;
} catch (std::exception const &err) {
throw Napi::Error::New(env, err.what());
} catch (...) {
throw Napi::Error::New(env, "Unknown error");
}
}

View File

@ -48,7 +48,11 @@ Napi::Value Blurple(const Napi::CallbackInfo &info) {
blob.length()));
result.Set("type", type);
return result;
} catch (Napi::Error const &err) {
throw err;
} catch (std::exception const &err) {
throw Napi::Error::New(env, err.what());
} catch (...) {
throw Napi::Error::New(env, "Unknown error");
}
}

View File

@ -68,7 +68,11 @@ Napi::Value Caption(const Napi::CallbackInfo &info) {
blob.length()));
result.Set("type", type);
return result;
} catch (Napi::Error const &err) {
throw err;
} catch (std::exception const &err) {
throw Napi::Error::New(env, err.what());
} catch (...) {
throw Napi::Error::New(env, "Unknown error");
}
}

View File

@ -66,7 +66,11 @@ Napi::Value CaptionTwo(const Napi::CallbackInfo &info) {
blob.length()));
result.Set("type", type);
return result;
} catch (Napi::Error const &err) {
throw err;
} catch (std::exception const &err) {
throw Napi::Error::New(env, err.what());
} catch (...) {
throw Napi::Error::New(env, "Unknown error");
}
}

View File

@ -47,7 +47,11 @@ Napi::Value Circle(const Napi::CallbackInfo &info) {
blob.length()));
result.Set("type", type);
return result;
} catch (Napi::Error const &err) {
throw err;
} catch (std::exception const &err) {
throw Napi::Error::New(env, err.what());
} catch (...) {
throw Napi::Error::New(env, "Unknown error");
}
}

View File

@ -55,7 +55,11 @@ Napi::Value Crop(const Napi::CallbackInfo &info) {
blob.length()));
result.Set("type", type);
return result;
} catch (Napi::Error const &err) {
throw err;
} catch (std::exception const &err) {
throw Napi::Error::New(env, err.what());
} catch (...) {
throw Napi::Error::New(env, "Unknown error");
}
}

View File

@ -48,7 +48,11 @@ Napi::Value Explode(const Napi::CallbackInfo &info) {
blob.length()));
result.Set("type", type);
return result;
} catch (Napi::Error const &err) {
throw err;
} catch (std::exception const &err) {
throw Napi::Error::New(env, err.what());
} catch (...) {
throw Napi::Error::New(env, "Unknown error");
}
}

View File

@ -56,7 +56,11 @@ Napi::Value Flag(const Napi::CallbackInfo &info) {
blob.length()));
result.Set("type", type);
return result;
} catch (Napi::Error const &err) {
throw err;
} catch (std::exception const &err) {
throw Napi::Error::New(env, err.what());
} catch (...) {
throw Napi::Error::New(env, "Unknown error");
}
}

View File

@ -49,7 +49,11 @@ Napi::Value Flip(const Napi::CallbackInfo &info) {
blob.length()));
result.Set("type", type);
return result;
} catch (Napi::Error const &err) {
throw err;
} catch (std::exception const &err) {
throw Napi::Error::New(env, err.what());
} catch (...) {
throw Napi::Error::New(env, "Unknown error");
}
}

View File

@ -44,7 +44,11 @@ Napi::Value Freeze(const Napi::CallbackInfo &info) {
blob.length()));
result.Set("type", type);
return result;
} catch (Napi::Error const &err) {
throw err;
} catch (std::exception const &err) {
throw Napi::Error::New(env, err.what());
} catch (...) {
throw Napi::Error::New(env, "Unknown error");
}
}

View File

@ -52,7 +52,11 @@ Napi::Value Gamexplain(const Napi::CallbackInfo &info) {
blob.length()));
result.Set("type", type);
return result;
} catch (Napi::Error const &err) {
throw err;
} catch (std::exception const &err) {
throw Napi::Error::New(env, err.what());
} catch (...) {
throw Napi::Error::New(env, "Unknown error");
}
}

View File

@ -69,7 +69,11 @@ Napi::Value Globe(const Napi::CallbackInfo &info) {
blob.length()));
result.Set("type", type);
return result;
} catch (Napi::Error const &err) {
throw err;
} catch (std::exception const &err) {
throw Napi::Error::New(env, err.what());
} catch (...) {
throw Napi::Error::New(env, "Unknown error");
}
}

View File

@ -31,7 +31,11 @@ Napi::Value Homebrew(const Napi::CallbackInfo &info) {
blob.length()));
result.Set("type", "png");
return result;
} catch (Napi::Error const &err) {
throw err;
} catch (std::exception const &err) {
throw Napi::Error::New(env, err.what());
} catch (...) {
throw Napi::Error::New(env, "Unknown error");
}
}

View File

@ -49,7 +49,11 @@ Napi::Value Invert(const Napi::CallbackInfo &info) {
blob.length()));
result.Set("type", type);
return result;
} catch (Napi::Error const &err) {
throw err;
} catch (std::exception const &err) {
throw Napi::Error::New(env, err.what());
} catch (...) {
throw Napi::Error::New(env, "Unknown error");
}
}

View File

@ -26,7 +26,11 @@ Napi::Value Jpeg(const Napi::CallbackInfo &info) {
blob.length()));
result.Set("type", "jpg");
return result;
} catch (Napi::Error const &err) {
throw err;
} catch (std::exception const &err) {
throw Napi::Error::New(env, err.what());
} catch (...) {
throw Napi::Error::New(env, "Unknown error");
}
}

View File

@ -53,7 +53,11 @@ Napi::Value Leak(const Napi::CallbackInfo &info) {
blob.length()));
result.Set("type", type);
return result;
} catch (Napi::Error const &err) {
throw err;
} catch (std::exception const &err) {
throw Napi::Error::New(env, err.what());
} catch (...) {
throw Napi::Error::New(env, "Unknown error");
}
}

View File

@ -49,7 +49,11 @@ Napi::Value Magik(const Napi::CallbackInfo &info) {
blob.length()));
result.Set("type", type);
return result;
} catch (Napi::Error const &err) {
throw err;
} catch (std::exception const &err) {
throw Napi::Error::New(env, err.what());
} catch (...) {
throw Napi::Error::New(env, "Unknown error");
}
}

View File

@ -86,7 +86,11 @@ Napi::Value Meme(const Napi::CallbackInfo &info) {
blob.length()));
result.Set("type", type);
return result;
} catch (Napi::Error const &err) {
throw err;
} catch (std::exception const &err) {
throw Napi::Error::New(env, err.what());
} catch (...) {
throw Napi::Error::New(env, "Unknown error");
}
}

View File

@ -84,7 +84,11 @@ Napi::Value Mirror(const Napi::CallbackInfo &info) {
blob.length()));
result.Set("type", type);
return result;
} catch (Napi::Error const &err) {
throw err;
} catch (std::exception const &err) {
throw Napi::Error::New(env, err.what());
} catch (...) {
throw Napi::Error::New(env, "Unknown error");
}
}

View File

@ -89,7 +89,11 @@ Napi::Value Motivate(const Napi::CallbackInfo &info) {
blob.length()));
result.Set("type", type);
return result;
} catch (Napi::Error const &err) {
throw err;
} catch (std::exception const &err) {
throw Napi::Error::New(env, err.what());
} catch (...) {
throw Napi::Error::New(env, "Unknown error");
}
}

View File

@ -68,7 +68,11 @@ Napi::Value Reddit(const Napi::CallbackInfo &info) {
blob.length()));
result.Set("type", type);
return result;
} catch (Napi::Error const &err) {
throw err;
} catch (std::exception const &err) {
throw Napi::Error::New(env, err.what());
} catch (...) {
throw Napi::Error::New(env, "Unknown error");
}
}

View File

@ -60,7 +60,11 @@ Napi::Value Resize(const Napi::CallbackInfo &info) {
blob.length()));
result.Set("type", type);
return result;
} catch (Napi::Error const &err) {
throw err;
} catch (std::exception const &err) {
throw Napi::Error::New(env, err.what());
} catch (...) {
throw Napi::Error::New(env, "Unknown error");
}
}

View File

@ -82,7 +82,11 @@ Napi::Value Retro(const Napi::CallbackInfo &info) {
blob.length()));
result.Set("type", "png");
return result;
} catch (Napi::Error const &err) {
throw err;
} catch (std::exception const &err) {
throw Napi::Error::New(env, err.what());
} catch (...) {
throw Napi::Error::New(env, "Unknown error");
}
}

View File

@ -49,7 +49,11 @@ Napi::Value Reverse(const Napi::CallbackInfo &info) {
blob.length()));
result.Set("type", "gif");
return result;
} catch (Napi::Error const &err) {
throw err;
} catch (std::exception const &err) {
throw Napi::Error::New(env, err.what());
} catch (...) {
throw Napi::Error::New(env, "Unknown error");
}
}

View File

@ -58,7 +58,11 @@ Napi::Value Scott(const Napi::CallbackInfo &info) {
blob.length()));
result.Set("type", type);
return result;
} catch (Napi::Error const &err) {
throw err;
} catch (std::exception const &err) {
throw Napi::Error::New(env, err.what());
} catch (...) {
throw Napi::Error::New(env, "Unknown error");
}
}

View File

@ -34,7 +34,11 @@ Napi::Value Sonic(const Napi::CallbackInfo &info) {
blob.length()));
result.Set("type", "png");
return result;
} catch (Napi::Error const &err) {
throw err;
} catch (std::exception const &err) {
throw Napi::Error::New(env, err.what());
} catch (...) {
throw Napi::Error::New(env, "Unknown error");
}
}

View File

@ -78,7 +78,11 @@ Napi::Value Speed(const Napi::CallbackInfo &info) {
blob.length()));
result.Set("type", type);
return result;
} catch (Napi::Error const &err) {
throw err;
} catch (std::exception const &err) {
throw Napi::Error::New(env, err.what());
} catch (...) {
throw Napi::Error::New(env, "Unknown error");
}
}

View File

@ -65,7 +65,11 @@ Napi::Value Spin(const Napi::CallbackInfo &info) {
blob.length()));
result.Set("type", "gif");
return result;
} catch (Napi::Error const &err) {
throw err;
} catch (std::exception const &err) {
throw Napi::Error::New(env, err.what());
} catch (...) {
throw Napi::Error::New(env, "Unknown error");
}
}

View File

@ -47,7 +47,11 @@ Napi::Value Swirl(const Napi::CallbackInfo &info) {
blob.length()));
result.Set("type", type);
return result;
} catch (Napi::Error const &err) {
throw err;
} catch (std::exception const &err) {
throw Napi::Error::New(env, err.what());
} catch (...) {
throw Napi::Error::New(env, "Unknown error");
}
}

View File

@ -61,7 +61,11 @@ Napi::Value Tile(const Napi::CallbackInfo &info) {
blob.length()));
result.Set("type", type);
return result;
} catch (Napi::Error const &err) {
throw err;
} catch (std::exception const &err) {
throw Napi::Error::New(env, err.what());
} catch (...) {
throw Napi::Error::New(env, "Unknown error");
}
}

View File

@ -58,7 +58,11 @@ Napi::Value Trump(const Napi::CallbackInfo &info) {
blob.length()));
result.Set("type", type);
return result;
} catch (Napi::Error const &err) {
throw err;
} catch (std::exception const &err) {
throw Napi::Error::New(env, err.what());
} catch (...) {
throw Napi::Error::New(env, "Unknown error");
}
}

View File

@ -55,7 +55,11 @@ Napi::Value Wall(const Napi::CallbackInfo &info) {
blob.length()));
result.Set("type", type);
return result;
} catch (Napi::Error const &err) {
throw err;
} catch (std::exception const &err) {
throw Napi::Error::New(env, err.what());
} catch (...) {
throw Napi::Error::New(env, "Unknown error");
}
}

View File

@ -83,7 +83,11 @@ Napi::Value Watermark(const Napi::CallbackInfo &info) {
blob.length()));
result.Set("type", type);
return result;
} catch (Napi::Error const &err) {
throw err;
} catch (std::exception const &err) {
throw Napi::Error::New(env, err.what());
} catch (...) {
throw Napi::Error::New(env, "Unknown error");
}
}

View File

@ -52,7 +52,11 @@ Napi::Value Wdt(const Napi::CallbackInfo &info) {
blob.length()));
result.Set("type", type);
return result;
} catch (Napi::Error const &err) {
throw err;
} catch (std::exception const &err) {
throw Napi::Error::New(env, err.what());
} catch (...) {
throw Napi::Error::New(env, "Unknown error");
}
}