From 42df2253eb99ab1ccba7c87d49b7ef954fe60d7b Mon Sep 17 00:00:00 2001 From: q-posev Date: Tue, 30 Mar 2021 16:03:34 +0200 Subject: [PATCH] better error handling --- src/templates_hdf5/templator_hdf5.org | 2 +- src/templates_text/templator_text.org | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/templates_hdf5/templator_hdf5.org b/src/templates_hdf5/templator_hdf5.org index 7da1889..f119ec7 100644 --- a/src/templates_hdf5/templator_hdf5.org +++ b/src/templates_hdf5/templator_hdf5.org @@ -123,7 +123,7 @@ trexio_exit_code trexio_hdf5_init(trexio_t* const file) { f->$group$_group = H5Gcreate(f->file_id, $GROUP$_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); break; } - assert (f->$group$_group > 0L); + if (f->$group$_group <= 0L) return TREXIO_INVALID_ID; return TREXIO_SUCCESS; } diff --git a/src/templates_text/templator_text.org b/src/templates_text/templator_text.org index 103a330..aa00eec 100644 --- a/src/templates_text/templator_text.org +++ b/src/templates_text/templator_text.org @@ -441,7 +441,7 @@ trexio_exit_code trexio_text_flush_$group$(trexio_text_t* const file) { if ($group$->to_flush == 0) return TREXIO_SUCCESS; FILE* f = $group$->file; - assert (f != NULL); + if (f == NULL) return TREXIO_INVALID_ARG_1; fseek(f, 0L, SEEK_SET); /* Write the dimensioning variables */