i am getting several error, that is ok, when the user reject, when the transaction was bad, and so on
but now i want to show differents message by their code error
in my service of my project i am getting this error
{code: 4001, message: 'MetaMask Tx Signature: User denied transaction', stack: '{\n "code": 4001,\n "message": "MetaMask Tx'}
this is my code
function getInformation=()=>{
try{
...
} catch (err) {
error = err
console.log('error', error) // error is the up message
throw new Error(error)
}
}
then i am using the getInformation function like this:
try{
...
const info= getInformation()
} catch (error) {
console.log('EERROR', error,error.code)
here i see the error as string
EERROR Error: [object Object]
at _callee$ (PWDService.js?9579:13)
at tryCatch (runtime.js?96cf:62)
at Generator.invoke [as _invoke] (runtime.js?96cf:296), undefined
and error.code is undefined, why i am getting as a string and error.code as undefined?
obviously error.code is undefined because error is an string