Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add error trace helpers #87

Merged
merged 1 commit into from
Mar 28, 2021
Merged

add error trace helpers #87

merged 1 commit into from
Mar 28, 2021

Conversation

sreimers
Copy link
Member

@sreimers sreimers commented Mar 26, 2021

Usage example:

#include <re.h>

int fn1(void);
int fn2(void);
int fn3(void);

int fn1(void) {
	int err;

	err = fn2();
	IF_ERR_RETURN(err);

	return 0;
}

int fn2(void) {
	int err;

	err = fn3();
	IF_ERR_RETURN(err);

	return 0;
}

int fn3(void) {
	int err;

	err = EINVAL;
	IF_ERR_RETURN(err);

	return 0;
}

int main(void)
{
	int err;

	err = fn1();
	IF_ERR_GOTO_OUT(err);

	return 0;
out:
	re_printf("error %d\n", err);
        return err;
}

make TRACE_ERR=1

Output after execution:

TRACE_ERR: src/main.c:29: fn3(): Invalid argument (22)
TRACE_ERR: src/main.c:20: fn2(): Invalid argument (22)
TRACE_ERR: src/main.c:11: fn1(): Invalid argument (22)
TRACE_ERR: src/main.c:39: main(): Invalid argument (22)
error 22

@codecov
Copy link

codecov bot commented Mar 26, 2021

Codecov Report

Merging #87 (1a7379a) into master (00fdc24) will increase coverage by 0.00%.
The diff coverage is n/a.

❗ Current head 1a7379a differs from pull request most recent head 221965f. Consider uploading reports for the commit 221965f to get more accurate results
Impacted file tree graph

@@           Coverage Diff           @@
##           master      #87   +/-   ##
=======================================
  Coverage   53.30%   53.31%           
=======================================
  Files         192      192           
  Lines       21473    21474    +1     
=======================================
+ Hits        11447    11449    +2     
+ Misses      10026    10025    -1     
Impacted Files Coverage Δ
src/dns/dname.c 72.04% <0.00%> (-3.23%) ⬇️
src/list/list.c 85.29% <0.00%> (-0.74%) ⬇️
src/mbuf/mbuf.c 79.06% <0.00%> (+0.12%) ⬆️
src/sip/transp.c 37.39% <0.00%> (+0.43%) ⬆️
src/json/decode.c 94.71% <0.00%> (+0.81%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 00fdc24...221965f. Read the comment docs.

@sreimers sreimers merged commit 9d1fbb6 into master Mar 28, 2021
@sreimers sreimers deleted the trace_err branch March 28, 2021 10:07
@sreimers sreimers added the enhancement New feature or request label Apr 9, 2021
@sreimers sreimers added this to the v2.0.0 milestone Apr 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

1 participant