[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis-gtk] branch master updated: error handling
From: |
gnunet |
Subject: |
[taler-anastasis-gtk] branch master updated: error handling |
Date: |
Thu, 18 Mar 2021 14:17:30 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository anastasis-gtk.
The following commit(s) were added to refs/heads/master by this push:
new 0bcd330 error handling
0bcd330 is described below
commit 0bcd33058ecb9916134b517bc53a766954921209
Author: Christian Grothoff <grothoff@gnunet.org>
AuthorDate: Thu Mar 18 14:17:27 2021 +0100
error handling
---
contrib/anastasis_gtk_main_window.glade | 4 ++
src/anastasis/anastasis-gtk_action.c | 85 +++++++++++++++++++++++----------
2 files changed, 64 insertions(+), 25 deletions(-)
diff --git a/contrib/anastasis_gtk_main_window.glade
b/contrib/anastasis_gtk_main_window.glade
index 03b97d8..21818f5 100644
--- a/contrib/anastasis_gtk_main_window.glade
+++ b/contrib/anastasis_gtk_main_window.glade
@@ -214,10 +214,14 @@ Author: Christian Grothoff, Dennis Neufeld
<object class="GtkLabel"
id="anastasis_gtk_error_label">
<property name="can-focus">False</property>
<property name="label"
translatable="yes">DYNAMIC ERROR MESSAGE</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
+ <property name="padding">10</property>
<property name="position">0</property>
</packing>
</child>
diff --git a/src/anastasis/anastasis-gtk_action.c
b/src/anastasis/anastasis-gtk_action.c
index 88229cc..f877cf9 100644
--- a/src/anastasis/anastasis-gtk_action.c
+++ b/src/anastasis/anastasis-gtk_action.c
@@ -1371,12 +1371,12 @@ action_challenge_selecting (void)
{
char *tmp;
- if (TALER_amount_add (&total,
- &total,
- &recovery_cost))
+ if (0 > TALER_amount_add (&total,
+ &total,
+ &recovery_cost))
{
GNUNET_break_op (0);
- AG_error ("Could not add up costs");
+ AG_error ("ERROR: Could not add up costs");
}
GNUNET_asprintf (&tmp,
"%s + %s",
@@ -1484,25 +1484,35 @@ static void
action_challenge_paying (void)
{
json_t *pprs;
- size_t index;
json_t *ppr;
GtkListStore *ls;
+ const char *uuid;
+ bool found = false;
+ const char *ps;
AG_hide_all_frames ();
ls = GTK_LIST_STORE (GCG_get_main_window_object (
"unpaid_qrcodes_liststore"));
gtk_list_store_clear (ls);
pprs = json_object_get (redux_state,
- "challenge_payment_requests");
- json_array_foreach (pprs, index, ppr)
+ "challenge_feedback");
+ json_object_foreach (pprs, uuid, ppr)
{
- const char *provider;
- const char *payto;
+ const char *state;
+ const char *payto = NULL;
+ const char *provider = NULL;
struct GNUNET_JSON_Specification spec[] = {
+ GNUNET_JSON_spec_string ("state",
+ &state),
+ GNUNET_JSON_spec_mark_optional (
+ GNUNET_JSON_spec_string ("taler_pay_uri",
+ &payto)),
+ GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_string ("provider",
- &provider),
- GNUNET_JSON_spec_string ("payto",
- &payto),
+ &provider)),
+ GNUNET_JSON_spec_mark_optional (
+ GNUNET_JSON_spec_string ("payment_secret",
+ &ps)),
GNUNET_JSON_spec_end ()
};
GdkPixbuf *pb;
@@ -1513,18 +1523,24 @@ action_challenge_paying (void)
NULL, NULL))
{
GNUNET_break (0);
+ json_dumpf (ppr,
+ stderr,
+ JSON_INDENT (2));
continue;
}
+ if (NULL == payto)
+ continue;
+ if (0 != strcmp (state,
+ "payment"))
+ continue;
+ found = true;
pb = setup_qrcode ("unpaid_qr_treeview",
payto,
strlen (payto));
if (NULL == pb)
- {
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
_ ("Failed to initialize QR-code pixbuf for `%s'\n"),
payto);
- continue;
- }
gtk_list_store_insert_with_values (ls,
NULL,
-1, /* append */
@@ -1533,28 +1549,35 @@ action_challenge_paying (void)
AG_UQRMC_PROVIDER, provider,
-1);
g_object_unref (pb);
+ break;
}
+ if (found)
{
json_t *args;
struct GNUNET_TIME_Relative timeout;
timeout = GNUNET_TIME_UNIT_MINUTES;
GNUNET_assert (NULL == ra);
- args = json_pack ("{s:o}",
+ args = json_pack ("{s:o, s:s}",
"timeout",
- GNUNET_JSON_from_time_rel (timeout));
+ GNUNET_JSON_from_time_rel (timeout),
+ "payment_secret",
+ ps);
ra = ANASTASIS_redux_action (redux_state,
- "await_payment",
+ "pay",
args,
&AG_action_cb,
NULL);
json_decref (args);
}
+ else
+ {
+ AG_error ("ERROR: Internal error: should pay, but do not know what");
+ }
AG_show ("anastasis_gtk_pay_frame");
AG_show ("anastasis_gtk_pay_image");
AG_show ("anastasis_gtk_main_control_vbox");
- AG_hide ("anastasis_gtk_main_window_unpaid_box");
AG_sensitive ("anastasis_gtk_main_window_prev_button");
AG_show ("anastasis_gtk_main_window_prev_button");
AG_hide ("anastasis_gtk_main_window_forward_button");
@@ -1791,14 +1814,22 @@ AG_action_cb (void *cls,
(void) cls;
ra = NULL;
AG_thaw ();
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Action result %d\n",
- error_code);
+#if DEBUG
+ fprintf (stderr,
+ "Action result %d\n",
+ error_code);
+ json_dumpf (response,
+ stderr,
+ JSON_INDENT (2));
+ fprintf (stderr,
+ "END action result %d\n",
+ error_code);
+#endif
if (TALER_EC_NONE != error_code)
{
- AG_error ("Error: %d\n",
+ AG_error ("Error: %s (%d)\n",
+ TALER_ErrorCode_get_hint (error_code),
error_code);
- /* FIXME: show error *nicely* in UI! */
if (in_action)
{
GNUNET_break (0);
@@ -1818,7 +1849,11 @@ AG_action_cb (void *cls,
return;
}
in_action = false;
- AG_error ("Unhandled state");
+ AG_error ("Unhandled state `%s/%s'",
+ json_string_value (json_object_get (redux_state,
+ "backup_state")),
+ json_string_value (json_object_get (redux_state,
+ "recovery_state")));
json_dumpf (redux_state,
stderr,
JSON_INDENT (2));
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-anastasis-gtk] branch master updated: error handling,
gnunet <=