diff --git a/src/libs/endorserServer.ts b/src/libs/endorserServer.ts index efdb021..20d1fbf 100644 --- a/src/libs/endorserServer.ts +++ b/src/libs/endorserServer.ts @@ -594,6 +594,31 @@ const planCache: LRUCache = new LRUCache({ max: 500, }); +/** + * Helpful for server errors, to get all the info -- including stuff skipped by toString & JSON.stringify + * + * @param error + */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export function errorStringForLog(error: any) { + let fullError = "" + error + " - JSON: " + JSON.stringify(error); + const errorResponseText = JSON.stringify(error.response); + // for some reason, error.response is not included in stringify result (eg. for 400 errors on invite redemptions) + if (!R.empty(errorResponseText) && !fullError.includes(errorResponseText)) { + // add error.response stuff + if (R.equals(error?.config, error?.response?.config)) { + // but exclude "config" because it's already in there + const newErrorResponseText = JSON.stringify( + R.omit(["config"] as never[], error.response), + ); + fullError += " - .response w/o same config JSON: " + newErrorResponseText; + } else { + fullError += " - .response JSON: " + errorResponseText; + } + } + return fullError; +} + /** * @param handleId nullable, in which case "undefined" will be returned * @param requesterDid optional, in which case no private info will be returned diff --git a/src/views/AccountViewView.vue b/src/views/AccountViewView.vue index 1a6ffd1..770c3a8 100644 --- a/src/views/AccountViewView.vue +++ b/src/views/AccountViewView.vue @@ -962,7 +962,7 @@ export default class AccountViewView extends Vue { group: "alert", type: "warning", title: "Cannot Set Notifications", - text: "This browser does not support notifications. Try Chrome or Safari, or other suggestions on the 'Troubleshoot your notifications' page.", + text: "This browser does not support notifications. Use Chrome, or install this to the home screen, or try other suggestions on the 'Troubleshoot your notifications' page.", }, 3000, ); diff --git a/src/views/ContactsView.vue b/src/views/ContactsView.vue index 75761cf..a69eba1 100644 --- a/src/views/ContactsView.vue +++ b/src/views/ContactsView.vue @@ -326,6 +326,7 @@ import TopMessage from "@/components/TopMessage.vue"; import { APP_SERVER, AppString, NotificationIface } from "@/constants/app"; import { db, + logConsoleAndDb, retrieveSettingsForActiveAccount, updateAccountSettings, updateDefaultSettings, @@ -337,6 +338,7 @@ import { CONTACT_CSV_HEADER, CONTACT_URL_PREFIX, createEndorserJwtForDid, + errorStringForLog, GiveSummaryRecord, getHeaders, isDid, @@ -511,7 +513,8 @@ export default class ContactsView extends Vue { ); // eslint-disable-next-line @typescript-eslint/no-explicit-any } catch (error: any) { - console.error("Error redeeming invite:", error); + const fullError = "Error redeeming invite: " + errorStringForLog(error); + logConsoleAndDb(fullError, true); let message = "Got an error sending the invite."; if ( error.response && @@ -670,7 +673,8 @@ export default class ContactsView extends Vue { this.givenToMeConfirmed = givenToMeConfirmed; this.givenToMeUnconfirmed = givenToMeUnconfirmed; } catch (error) { - console.error("Error loading gives", error); + const fullError = "Error loading gives: " + errorStringForLog(error); + logConsoleAndDb(fullError, true); this.$notify( { group: "alert", @@ -719,6 +723,9 @@ export default class ContactsView extends Vue { 3000, // keeping it up so that the "visibility" message is seen ); } catch (e) { + const fullError = + "Error adding contacts from CSV: " + errorStringForLog(e); + logConsoleAndDb(fullError, true); this.danger("An error occurred. Some contacts may have been added."); } @@ -785,6 +792,9 @@ export default class ContactsView extends Vue { query: { contacts: JSON.stringify(contacts) }, }); } catch (e) { + const fullError = + "Error adding contacts from array: " + errorStringForLog(e); + logConsoleAndDb(fullError, true); this.danger("The input could not be parsed.", "Invalid Contact List"); } return; @@ -934,7 +944,9 @@ export default class ContactsView extends Vue { ); }) .catch((err) => { - console.error("Error when adding contact to storage:", err); + const fullError = + "Error when adding contact to storage: " + errorStringForLog(err); + logConsoleAndDb(fullError, true); let message = "An error prevented this import."; if ( err.message?.indexOf("Key already exists in the object store.") > -1 @@ -1011,7 +1023,8 @@ export default class ContactsView extends Vue { ); } } catch (error) { - console.error("Error when registering:", error); + const fullError = "Error when registering: " + errorStringForLog(error); + logConsoleAndDb(fullError, true); let userMessage = "There was an error."; const serverError = error as AxiosError; if (serverError.isAxiosError) { @@ -1197,6 +1210,9 @@ export default class ContactsView extends Vue { showContactGivesInline: newShowValue, }); } catch (err) { + const fullError = + "Error updating contact-amounts setting: " + errorStringForLog(err); + logConsoleAndDb(fullError, true); this.$notify( { group: "alert", @@ -1206,10 +1222,6 @@ export default class ContactsView extends Vue { }, 5000, ); - console.error( - "Telling user to try again after contact-amounts setting update because:", - err, - ); } this.showGiveNumbers = newShowValue; if ( diff --git a/src/views/InviteOneAcceptView.vue b/src/views/InviteOneAcceptView.vue index 716cc39..398a3e4 100644 --- a/src/views/InviteOneAcceptView.vue +++ b/src/views/InviteOneAcceptView.vue @@ -8,8 +8,10 @@ here.

- If the link looks correct, try Chrome. (For example, iOS Safari does not - work well with the invite link.) + If the link looks correct, try Chrome. (For example, iOS may have cut + off the invite data, or it may have shown a preview that stole your + invite.) If it still complains, you may need the person who invited you + to send a new one.