@@ -54,23 +54,23 @@ status_t api_get_tips(const iota_client_service_t* const service, char** json_re
54
54
55
55
if (res == NULL ) {
56
56
ret = SC_CCLIENT_OOM ;
57
- ta_log_error ("%s\n" , "SC_CCLIENT_OOM" );
57
+ ta_log_error ("%s\n" , ta_error_to_string ( ret ) );
58
58
goto done ;
59
59
}
60
60
61
61
lock_handle_lock (& cjson_lock );
62
62
if (iota_client_get_tips (service , res ) != RC_OK ) {
63
63
lock_handle_unlock (& cjson_lock );
64
64
ret = SC_CCLIENT_FAILED_RESPONSE ;
65
- ta_log_error ("%s\n" , "SC_CCLIENT_FAILED_RESPONSE" );
65
+ ta_log_error ("%s\n" , ta_error_to_string ( ret ) );
66
66
goto done ;
67
67
}
68
68
lock_handle_unlock (& cjson_lock );
69
69
70
70
ret = ta_get_tips_res_serialize (res , json_result );
71
71
if (ret != SC_OK ) {
72
72
ret = SC_CCLIENT_JSON_PARSE ;
73
- ta_log_error ("%s\n" , "SC_CCLIENT_JSON_PARSE" );
73
+ ta_log_error ("%s\n" , ta_error_to_string ( ret ) );
74
74
goto done ;
75
75
}
76
76
@@ -88,7 +88,7 @@ status_t api_get_tips_pair(const iota_config_t* const iconf, const iota_client_s
88
88
89
89
if (req == NULL || res == NULL || res_buff == NULL ) {
90
90
ret = SC_TA_OOM ;
91
- ta_log_error ("%s\n" , "SC_TA_OOM" );
91
+ ta_log_error ("%s\n" , ta_error_to_string ( ret ) );
92
92
goto done ;
93
93
}
94
94
@@ -97,21 +97,21 @@ status_t api_get_tips_pair(const iota_config_t* const iconf, const iota_client_s
97
97
if (iota_client_get_transactions_to_approve (service , req , res ) != RC_OK ) {
98
98
lock_handle_unlock (& cjson_lock );
99
99
ret = SC_CCLIENT_FAILED_RESPONSE ;
100
- ta_log_error ("%s\n" , "SC_CCLIENT_FAILED_RESPONSE" );
100
+ ta_log_error ("%s\n" , ta_error_to_string ( ret ) );
101
101
goto done ;
102
102
}
103
103
lock_handle_unlock (& cjson_lock );
104
104
105
105
if (service -> serializer .vtable .get_transactions_to_approve_serialize_response (res , res_buff ) != RC_OK ) {
106
106
ret = SC_CCLIENT_JSON_PARSE ;
107
- ta_log_error ("%s\n" , "SC_CCLIENT_JSON_PARSE" );
107
+ ta_log_error ("%s\n" , ta_error_to_string ( ret ) );
108
108
goto done ;
109
109
}
110
110
111
111
* json_result = (char * )malloc ((res_buff -> length + 1 ) * sizeof (char ));
112
112
if (* json_result == NULL ) {
113
113
ret = SC_CCLIENT_JSON_PARSE ;
114
- ta_log_error ("%s\n" , "SC_CCLIENT_JSON_PARSE" );
114
+ ta_log_error ("%s\n" , ta_error_to_string ( ret ) );
115
115
goto done ;
116
116
}
117
117
snprintf (* json_result , (res_buff -> length + 1 ), "%s" , res_buff -> data );
@@ -129,7 +129,7 @@ status_t api_generate_address(const iota_config_t* const iconf, const iota_clien
129
129
ta_generate_address_res_t * res = ta_generate_address_res_new ();
130
130
if (res == NULL ) {
131
131
ret = SC_TA_OOM ;
132
- ta_log_error ("%s\n" , "SC_TA_OOM" );
132
+ ta_log_error ("%s\n" , ta_error_to_string ( ret ) );
133
133
goto done ;
134
134
}
135
135
@@ -157,7 +157,7 @@ status_t api_find_transaction_object_single(const iota_client_service_t* const s
157
157
transaction_array_t * res = transaction_array_new ();
158
158
if (req == NULL || res == NULL ) {
159
159
ret = SC_TA_OOM ;
160
- ta_log_error ("%s\n" , "SC_TA_OOM" );
160
+ ta_log_error ("%s\n" , ta_error_to_string ( ret ) );
161
161
goto done ;
162
162
}
163
163
@@ -188,7 +188,7 @@ status_t api_find_transaction_objects(const iota_client_service_t* const service
188
188
transaction_array_t * res = transaction_array_new ();
189
189
if (req == NULL || res == NULL ) {
190
190
ret = SC_TA_OOM ;
191
- ta_log_error ("%s\n" , "SC_TA_OOM" );
191
+ ta_log_error ("%s\n" , ta_error_to_string ( ret ) );
192
192
goto done ;
193
193
}
194
194
@@ -226,11 +226,11 @@ status_t api_find_transactions_by_tag(const iota_client_service_t* const service
226
226
find_transactions_res_t * res = find_transactions_res_new ();
227
227
if (req == NULL || res == NULL ) {
228
228
ret = SC_TA_OOM ;
229
- ta_log_error ("%s\n" , "SC_TA_OOM" );
229
+ ta_log_error ("%s\n" , ta_error_to_string ( ret ) );
230
230
goto done ;
231
231
}
232
232
233
- // If 'tag' is less than 27 trytes (NUM_TRYTES_TAG), expands it
233
+ // If 'tag' is less than 27 trytes (NUM_TRYTES_TAG), expand it
234
234
if (strnlen (obj , NUM_TRYTES_TAG ) < NUM_TRYTES_TAG ) {
235
235
char new_tag [NUM_TRYTES_TAG + 1 ];
236
236
// Fill in '9' to get valid tag (27 trytes)
@@ -244,15 +244,15 @@ status_t api_find_transactions_by_tag(const iota_client_service_t* const service
244
244
245
245
if (find_transactions_req_tag_add (req , tag_trits ) != RC_OK ) {
246
246
ret = SC_CCLIENT_INVALID_FLEX_TRITS ;
247
- ta_log_error ("%s\n" , "SC_CCLIENT_INVALID_FLEX_TRITS" );
247
+ ta_log_error ("%s\n" , ta_error_to_string ( ret ) );
248
248
goto done ;
249
249
}
250
250
251
251
lock_handle_lock (& cjson_lock );
252
252
if (iota_client_find_transactions (service , req , res ) != RC_OK ) {
253
253
lock_handle_unlock (& cjson_lock );
254
254
ret = SC_CCLIENT_FAILED_RESPONSE ;
255
- ta_log_error ("%s\n" , "SC_CCLIENT_FAILED_RESPONSE" );
255
+ ta_log_error ("%s\n" , ta_error_to_string ( ret ) );
256
256
goto done ;
257
257
}
258
258
lock_handle_unlock (& cjson_lock );
@@ -273,7 +273,7 @@ status_t api_find_transactions_obj_by_tag(const iota_client_service_t* const ser
273
273
transaction_array_t * res = transaction_array_new ();
274
274
if (req == NULL || res == NULL ) {
275
275
ret = SC_TA_OOM ;
276
- ta_log_error ("%s\n" , "SC_TA_OOM" );
276
+ ta_log_error ("%s\n" , ta_error_to_string ( ret ) );
277
277
goto done ;
278
278
}
279
279
@@ -291,7 +291,7 @@ status_t api_find_transactions_obj_by_tag(const iota_client_service_t* const ser
291
291
292
292
if (find_transactions_req_tag_add (req , tag_trits ) != RC_OK ) {
293
293
ret = SC_CCLIENT_INVALID_FLEX_TRITS ;
294
- ta_log_error ("%s\n" , "SC_CCLIENT_INVALID_FLEX_TRITS" );
294
+ ta_log_error ("%s\n" , ta_error_to_string ( ret ) );
295
295
goto done ;
296
296
}
297
297
@@ -319,7 +319,7 @@ status_t api_recv_mam_message(const iota_config_t* const iconf, const iota_clien
319
319
mam_api_t mam ;
320
320
ta_recv_mam_req_t * req = recv_mam_req_new ();
321
321
if (req == NULL ) {
322
- ta_log_error ("%s\n" , "SC_TA_OOM" );
322
+ ta_log_error ("%s\n" , ta_error_to_string ( ret ) );
323
323
return SC_TA_OOM ;
324
324
}
325
325
bundle_array_t * bundle_array = NULL ;
@@ -336,7 +336,7 @@ status_t api_recv_mam_message(const iota_config_t* const iconf, const iota_clien
336
336
recv_mam_data_id_mam_v1_t * data_id = (recv_mam_data_id_mam_v1_t * )req -> data_id ;
337
337
if (mam_api_init (& mam , (tryte_t * )iconf -> seed ) != RC_OK ) {
338
338
ret = SC_MAM_FAILED_INIT ;
339
- ta_log_error ("%s\n" , "SC_MAM_FAILED_INIT" );
339
+ ta_log_error ("%s\n" , ta_error_to_string ( ret ) );
340
340
goto done ;
341
341
}
342
342
@@ -370,7 +370,7 @@ status_t api_recv_mam_message(const iota_config_t* const iconf, const iota_clien
370
370
retcode_t rc = ta_mam_api_bundle_read (& mam , bundle , & payload );
371
371
if (rc != RC_OK ) {
372
372
ret = SC_MAM_FAILED_RESPONSE ;
373
- ta_log_error ("%s\n" , "SC_MAM_FAILED_RESPONSE" );
373
+ ta_log_error ("%s\n" , ta_error_to_string ( ret ) );
374
374
goto done ;
375
375
}
376
376
@@ -387,11 +387,11 @@ status_t api_recv_mam_message(const iota_config_t* const iconf, const iota_clien
387
387
// Destroying MAM API
388
388
if (ret != SC_MAM_FAILED_INIT ) {
389
389
if (mam_api_save (& mam , iconf -> mam_file_path , NULL , 0 ) != RC_OK ) {
390
- ta_log_error ("%s\n" , "SC_MAM_FILE_SAVE" );
390
+ ta_log_error ("%s\n" , ta_error_to_string ( ret ) );
391
391
}
392
392
if (mam_api_destroy (& mam ) != RC_OK ) {
393
393
ret = SC_MAM_FAILED_DESTROYED ;
394
- ta_log_error ("%s\n" , "SC_MAM_FAILED_DESTROYED" );
394
+ ta_log_error ("%s\n" , ta_error_to_string ( ret ) );
395
395
}
396
396
}
397
397
bundle_array_free (& bundle_array );
@@ -421,7 +421,7 @@ status_t api_send_mam_message(const ta_config_t* const info, const iota_config_t
421
421
if (send_mam_req_deserialize (payload , req )) {
422
422
lock_handle_unlock (& cjson_lock );
423
423
ret = SC_MAM_FAILED_INIT ;
424
- ta_log_error ("%s\n" , "SC_MAM_FAILED_INIT" );
424
+ ta_log_error ("%s\n" , ta_error_to_string ( ret ) );
425
425
goto done ;
426
426
}
427
427
lock_handle_unlock (& cjson_lock );
@@ -456,7 +456,7 @@ status_t api_send_mam_message(const ta_config_t* const info, const iota_config_t
456
456
if (ta_send_bundle (info , iconf , service , bundle ) != SC_OK ) {
457
457
lock_handle_unlock (& cjson_lock );
458
458
ret = SC_MAM_FAILED_RESPONSE ;
459
- ta_log_error ("%s\n" , "SC_MAM_FAILED_RESPONSE" );
459
+ ta_log_error ("%s\n" , ta_error_to_string ( ret ) );
460
460
goto done ;
461
461
}
462
462
lock_handle_unlock (& cjson_lock );
@@ -499,7 +499,7 @@ status_t api_send_mam_message(const ta_config_t* const info, const iota_config_t
499
499
if (ta_send_bundle (info , iconf , service , bundle ) != SC_OK ) {
500
500
lock_handle_unlock (& cjson_lock );
501
501
ret = SC_MAM_FAILED_RESPONSE ;
502
- ta_log_error ("%s\n" , "SC_MAM_FAILED_RESPONSE" );
502
+ ta_log_error ("%s\n" , ta_error_to_string ( ret ) );
503
503
goto done ;
504
504
}
505
505
lock_handle_unlock (& cjson_lock );
@@ -529,11 +529,12 @@ status_t api_send_mam_message(const ta_config_t* const info, const iota_config_t
529
529
if (ret != SC_MAM_FAILED_INIT ) {
530
530
// If `seed` is not assigned, then the local MAM file will be used. Therefore, we need to close the MAM file.
531
531
if (!data -> seed && mam_api_save (& mam , iconf -> mam_file_path , NULL , 0 ) != RC_OK ) {
532
- ta_log_error ("%s\n" , "SC_MAM_FILE_SAVE" );
532
+ ret = SC_MAM_FILE_SAVE ;
533
+ ta_log_error ("%s\n" , ta_error_to_string (ret ));
533
534
}
534
535
if (mam_api_destroy (& mam )) {
535
536
ret = SC_MAM_FAILED_DESTROYED ;
536
- ta_log_error ("%s\n" , "SC_MAM_FAILED_DESTROYED" );
537
+ ta_log_error ("%s\n" , ta_error_to_string ( ret ) );
537
538
}
538
539
}
539
540
bundle_transactions_free (& bundle );
@@ -553,7 +554,7 @@ status_t api_send_transfer(const ta_core_t* const core, const char* const obj, c
553
554
554
555
if (req == NULL || res == NULL || txn_obj_req == NULL || res_txn_array == NULL ) {
555
556
ret = SC_TA_OOM ;
556
- ta_log_error ("%s\n" , "SC_TA_OOM" );
557
+ ta_log_error ("%s\n" , ta_error_to_string ( ret ) );
557
558
goto done ;
558
559
}
559
560
@@ -623,7 +624,7 @@ status_t api_send_trytes(const ta_config_t* const info, const iota_config_t* con
623
624
624
625
if (!trytes ) {
625
626
ret = SC_TA_OOM ;
626
- ta_log_error ("%s\n" , "SC_TA_OOM" );
627
+ ta_log_error ("%s\n" , ta_error_to_string ( ret ) );
627
628
goto done ;
628
629
}
629
630
0 commit comments