Skip to content
This repository has been archived by the owner on Mar 16, 2023. It is now read-only.

Commit

Permalink
feat(sdk): log gsn error in production mode
Browse files Browse the repository at this point in the history
  • Loading branch information
LeilaWang committed Feb 10, 2020
1 parent 0c763d5 commit 93927d3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import {
GSNProvider,
} from '@openzeppelin/gsn-provider';
import Web3Service from '~/helpers/Web3Service';
import {
errorLogProduction,
} from '~/utils/log';
import retrieveSigningInfo from '~/utils/retrieveSigningInfo';
import { getProviderUrl } from '~/utils/network';
import makeApproveFunction from './makeApproveFunction';
Expand Down Expand Up @@ -44,7 +47,10 @@ const sendTransaction = async (query, connection) => {
responseId,
};
} catch (e) {
let error = e;
errorLogProduction(e);
let error = {
key: 'transaction.gsn.error',
};
if (error.message.match(/relayer/)) {
error = {
key: 'transaction.gsn.error.relayer',
Expand Down
1 change: 1 addition & 0 deletions packages/extension/src/ui/locales/en/transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export default {
submit: 'Send',
},
error: {
_: 'GSN is not available at the moment. Please try again later.',
relayer: 'Relayer is not available at the moment. Please try again later.',
},
},
Expand Down
13 changes: 8 additions & 5 deletions packages/extension/src/utils/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,18 @@ export function warnLog(...args) {
}
}


export function warnLogProduction(...args) {
console.warn(...args); // eslint-disable-line no-console
}

export function log(...args) {
if (process.env.NODE_ENV !== 'production') {
console.log(...args); // eslint-disable-line no-console
}
}

export function errorLogProduction(...args) {
console.error(...args); // eslint-disable-line no-console
}

export function warnLogProduction(...args) {
console.warn(...args); // eslint-disable-line no-console
}

export default log;

0 comments on commit 93927d3

Please sign in to comment.