mirror of
https://github.com/ecency/ecency-mobile.git
synced 2025-01-05 21:06:21 +03:00
try catch
This commit is contained in:
parent
06c4668eb5
commit
7dd9b6cfc1
@ -50,8 +50,15 @@ export const Login = (username, password) => {
|
|||||||
resultKeys[pubKey] = publicKeys[pubKey];
|
resultKeys[pubKey] = publicKeys[pubKey];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
let jsonMetadata;
|
||||||
const jsonMetadata = JSON.parse(account.json_metadata);
|
try {
|
||||||
|
jsonMetadata = JSON.parse(account.json_metadata);
|
||||||
|
}
|
||||||
|
catch(err) {
|
||||||
|
jsonMetadata = '';
|
||||||
|
//TODO: handle wrong json format properly
|
||||||
|
//reject(new Error(err));
|
||||||
|
}
|
||||||
if (Object.keys(jsonMetadata).length !== 0) {
|
if (Object.keys(jsonMetadata).length !== 0) {
|
||||||
avatar = jsonMetadata.profile.profile_image || '';
|
avatar = jsonMetadata.profile.profile_image || '';
|
||||||
}
|
}
|
||||||
@ -76,14 +83,14 @@ export const Login = (username, password) => {
|
|||||||
updateCurrentUsername(account.name);
|
updateCurrentUsername(account.name);
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
reject(new Error('Invalid credentails, please check and try again'));
|
reject(new Error('Invalid credentials, please check and try again'));
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
reject(new Error('Invalid credentails, please check and try again'));
|
reject(new Error('Invalid credentials, please check and try again'));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
reject(new Error('Invalid credentails, please check and try again'));
|
reject(new Error('Invalid credentials, please check and try again'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -100,7 +107,7 @@ export const loginWithSC2 = async (accessToken) => {
|
|||||||
avatar = jsonMetadata.profile.profile_image;
|
avatar = jsonMetadata.profile.profile_image;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
reject(new Error('Invalid credentails, please check and try again'));
|
reject(new Error('Invalid credentials, please check and try again'));
|
||||||
}
|
}
|
||||||
const userData = {
|
const userData = {
|
||||||
username: account.account.name,
|
username: account.account.name,
|
||||||
|
Loading…
Reference in New Issue
Block a user