mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-17 02:13:34 +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];
|
||||
}
|
||||
});
|
||||
|
||||
const jsonMetadata = JSON.parse(account.json_metadata);
|
||||
let jsonMetadata;
|
||||
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) {
|
||||
avatar = jsonMetadata.profile.profile_image || '';
|
||||
}
|
||||
@ -76,14 +83,14 @@ export const Login = (username, password) => {
|
||||
updateCurrentUsername(account.name);
|
||||
})
|
||||
.catch(() => {
|
||||
reject(new Error('Invalid credentails, please check and try again'));
|
||||
reject(new Error('Invalid credentials, please check and try again'));
|
||||
});
|
||||
} else {
|
||||
reject(new Error('Invalid credentails, please check and try again'));
|
||||
reject(new Error('Invalid credentials, please check and try again'));
|
||||
}
|
||||
})
|
||||
.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;
|
||||
}
|
||||
} catch (error) {
|
||||
reject(new Error('Invalid credentails, please check and try again'));
|
||||
reject(new Error('Invalid credentials, please check and try again'));
|
||||
}
|
||||
const userData = {
|
||||
username: account.account.name,
|
||||
|
Loading…
Reference in New Issue
Block a user