Browse code

secfilter: Convert error messages to error responses in secf_rpc_add_dst()

Olle E. Johansson authored on 03/01/2022 15:33:08
Showing 1 changed files
... ...
@@ -63,7 +63,7 @@ void secf_rpc_add_dst(rpc_t *rpc, void *ctx)
63 63
 	char *text = NULL;
64 64
 
65 65
 	if(rpc->scan(ctx, "d", &number) < 1) {
66
-		rpc->fault(ctx, 0,
66
+		rpc->fault(ctx, 500,
67 67
 				"Invalid Parameters. Usage: secfilter.add_dst "
68 68
 				"number\n     Example: secfilter.add_dst "
69 69
 				"555123123");
... ...
@@ -73,7 +73,7 @@ void secf_rpc_add_dst(rpc_t *rpc, void *ctx)
73 73
 	data.s = pkg_malloc(data.len * sizeof(char));
74 74
 	if(!data.s) {
75 75
 		PKG_MEM_ERROR;
76
-		rpc->rpl_printf(ctx, "Error insert values in the blacklist");
76
+		rpc->fault(ctx, 500, "Error insert values in the blacklist");
77 77
 		return;
78 78
 	}
79 79
 	memcpy(data.s, text, data.len);
... ...
@@ -82,7 +82,7 @@ void secf_rpc_add_dst(rpc_t *rpc, void *ctx)
82 82
 		rpc->rpl_printf(ctx,
83 83
 				"Values (%s) inserted into blacklist destinations", data);
84 84
 	} else {
85
-		rpc->rpl_printf(ctx, "Error insert values in the blacklist");
85
+		rpc->fault(ctx, 500, "Error insert values in the blacklist");
86 86
 	}
87 87
 	lock_release(&secf_data->lock);
88 88
 	if(data.s)