Skip to content

Commit fccc7ad

Browse files
Initial definition for TSK_TRACE_ERRORS
1 parent af33ed1 commit fccc7ad

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

c/tskit/core.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* MIT License
33
*
4-
* Copyright (c) 2019-2024 Tskit Developers
4+
* Copyright (c) 2019-2025 Tskit Developers
55
* Copyright (c) 2015-2018 University of Oxford
66
*
77
* Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -953,6 +953,21 @@ not be freed by client code.
953953
*/
954954
const char *tsk_strerror(int err);
955955

956+
#ifndef TSK_TRACE_ERRORS
957+
958+
static inline int
959+
_tsk_trace_error(int err, int line, const char *file)
960+
{
961+
fprintf(stderr, "tskit-trace-error: %d='%s' at line %d in %s\n", err,
962+
tsk_strerror(err), line, file);
963+
return err;
964+
}
965+
966+
#define tsk_trace_error(err) (_tsk_trace_error(err, __LINE__, __FILE__))
967+
#else
968+
#define tsk_trace_error(err) (err)
969+
#endif
970+
956971
#ifndef TSK_BUG_ASSERT_MESSAGE
957972
#define TSK_BUG_ASSERT_MESSAGE \
958973
"If you are using tskit directly please open an issue on" \

c/tskit/tables.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* MIT License
33
*
4-
* Copyright (c) 2019-2023 Tskit Developers
4+
* Copyright (c) 2019-2025 Tskit Developers
55
* Copyright (c) 2017-2018 University of Oxford
66
*
77
* Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -10997,7 +10997,7 @@ tsk_table_collection_check_integrity(
1099710997
}
1099810998

1099910999
if (self->sequence_length <= 0) {
11000-
ret = TSK_ERR_BAD_SEQUENCE_LENGTH;
11000+
ret = tsk_trace_error(TSK_ERR_BAD_SEQUENCE_LENGTH);
1100111001
goto out;
1100211002
}
1100311003
ret = tsk_table_collection_check_offsets(self);

0 commit comments

Comments
 (0)