error handling
This commit is contained in:
parent
7523dcab95
commit
3c85a0d14e
@ -85,6 +85,10 @@ async function callBackend<T extends MessageType>(
|
|||||||
): Promise<MessageMap[T]["response"]> {
|
): Promise<MessageMap[T]["response"]> {
|
||||||
return new Promise<MessageMap[T]["response"]>((resolve, reject) => {
|
return new Promise<MessageMap[T]["response"]>((resolve, reject) => {
|
||||||
chrome.runtime.sendMessage({ type, detail }, (resp) => {
|
chrome.runtime.sendMessage({ type, detail }, (resp) => {
|
||||||
|
if (chrome.runtime.lastError) {
|
||||||
|
console.log("Error calling backend");
|
||||||
|
reject(new Error(`Error contacting backend: chrome.runtime.lastError.message`));
|
||||||
|
}
|
||||||
if (typeof resp === "object" && resp && resp.error) {
|
if (typeof resp === "object" && resp && resp.error) {
|
||||||
console.warn("response error:", resp)
|
console.warn("response error:", resp)
|
||||||
const e = new WalletApiError(resp.error.message, resp.error);
|
const e = new WalletApiError(resp.error.message, resp.error);
|
||||||
|
Loading…
Reference in New Issue
Block a user