forked from trent_larson/crowd-funder-for-time-pwa
add more debug information on errors caught from server
This commit is contained in:
@@ -594,6 +594,31 @@ const planCache: LRUCache<string, PlanSummaryRecord> = 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
|
||||
|
||||
@@ -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,
|
||||
);
|
||||
|
||||
@@ -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 (
|
||||
|
||||
@@ -8,8 +8,10 @@
|
||||
here.
|
||||
</p>
|
||||
<p class="mt-2">
|
||||
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.
|
||||
</p>
|
||||
<textarea
|
||||
v-model="inputJwt"
|
||||
@@ -42,8 +44,13 @@ import { Router } from "vue-router";
|
||||
|
||||
import QuickNav from "@/components/QuickNav.vue";
|
||||
import { NotificationIface } from "@/constants/app";
|
||||
import { db, retrieveSettingsForActiveAccount } from "@/db/index";
|
||||
import {
|
||||
db,
|
||||
logConsoleAndDb,
|
||||
retrieveSettingsForActiveAccount,
|
||||
} from "@/db/index";
|
||||
import { decodeEndorserJwt } from "@/libs/crypto/vc";
|
||||
import { errorStringForLog } from "@/libs/endorserServer";
|
||||
import { generateSaveAndActivateIdentity } from "@/libs/util";
|
||||
|
||||
@Component({ components: { QuickNav } })
|
||||
@@ -124,7 +131,8 @@ export default class InviteOneAcceptView extends Vue {
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error accepting invite:", error);
|
||||
const fullError = "Error accepting invite: " + errorStringForLog(error);
|
||||
logConsoleAndDb(fullError, true);
|
||||
if (notifyOnFailure) {
|
||||
this.$notify(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user