diff options
author | Braden Bodily <thebodily@gmail.com> | 2019-08-14 20:57:49 -0600 |
---|---|---|
committer | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-08-17 12:33:15 +0200 |
commit | 71d71d55b5c0d6da4d1555823ac432bf0b33389a (patch) | |
tree | 20b2e819d599d6d1bd459bb51880c31e97cfe825 /drivers/png | |
parent | 40640a01dc90be00e55e4eef3c7800401ef63b18 (diff) |
Replace 'ERR_EXPLAIN' with 'ERR_FAIL_*_MSG' in 'core/' and 'editor/'
Condensed some if and ERR statements. Added dots to end of error messages
Couldn't figure out EXPLAINC. These files gave me trouble: core/error_macros.h, core/io/file_access_buffered_fa.h (where is it?),
core/os/memory.cpp,
drivers/png/png_driver_common.cpp,
drivers/xaudio2/audio_driver_xaudio2.cpp (where is it?)
Diffstat (limited to 'drivers/png')
-rw-r--r-- | drivers/png/png_driver_common.cpp | 9 | ||||
-rw-r--r-- | drivers/png/resource_saver_png.cpp | 5 |
2 files changed, 6 insertions, 8 deletions
diff --git a/drivers/png/png_driver_common.cpp b/drivers/png/png_driver_common.cpp index 0e849bf2fe..7deac1d118 100644 --- a/drivers/png/png_driver_common.cpp +++ b/drivers/png/png_driver_common.cpp @@ -97,7 +97,7 @@ Error png_to_image(const uint8_t *p_source, size_t p_size, Ref<Image> p_image) { break; default: png_image_free(&png_img); // only required when we return before finish_read - ERR_PRINT("Unsupported png format"); + ERR_PRINT("Unsupported png format."); return ERR_UNAVAILABLE; } @@ -179,10 +179,9 @@ Error image_to_png(const Ref<Image> &p_image, PoolVector<uint8_t> &p_buffer) { ERR_FAIL_COND_V(check_error(png_img), FAILED); } if (!success) { - if (compressed_size <= png_size_estimate) { - // buffer was big enough, must be some other error - ERR_FAIL_V(FAILED); - } + + // buffer was big enough, must be some other error + ERR_FAIL_COND_V(compressed_size <= png_size_estimate, FAILED); // write failed due to buffer size, resize and retry Error err = p_buffer.resize(buffer_offset + compressed_size); diff --git a/drivers/png/resource_saver_png.cpp b/drivers/png/resource_saver_png.cpp index 43a30f055b..7a2eeafdc3 100644 --- a/drivers/png/resource_saver_png.cpp +++ b/drivers/png/resource_saver_png.cpp @@ -39,9 +39,8 @@ Error ResourceSaverPNG::save(const String &p_path, const RES &p_resource, uint32 Ref<ImageTexture> texture = p_resource; - ERR_FAIL_COND_V(!texture.is_valid(), ERR_INVALID_PARAMETER); - ERR_EXPLAIN("Can't save empty texture as PNG"); - ERR_FAIL_COND_V(!texture->get_width() || !texture->get_height(), ERR_INVALID_PARAMETER); + ERR_FAIL_COND_V_MSG(!texture.is_valid(), ERR_INVALID_PARAMETER, "Can't save invalid texture as PNG."); + ERR_FAIL_COND_V_MSG(!texture->get_width(), ERR_INVALID_PARAMETER, "Can't save empty texture as PNG."); Ref<Image> img = texture->get_data(); |