added compulary context message to all logError calls

This commit is contained in:
Abhinav-grd 2021-09-01 18:04:18 +05:30
parent 39d93c4f79
commit 7dfd6658ea
12 changed files with 21 additions and 25 deletions

View file

@ -472,7 +472,7 @@ export default function App({ Component, err }) {
HTTPService.getInterceptors().response.use( HTTPService.getInterceptors().response.use(
(resp) => resp, (resp) => resp,
(error) => { (error) => {
logError(error); logError(error, 'Network Error');
return Promise.reject(error); return Promise.reject(error);
} }
); );

View file

@ -57,7 +57,7 @@ export default function Credentials() {
keyAttributes.memLimit keyAttributes.memLimit
); );
} catch (e) { } catch (e) {
console.error('failed to deriveKey ', e.message); logError(e, 'failed to derive key');
throw e; throw e;
} }
try { try {
@ -78,7 +78,7 @@ export default function Credentials() {
router.push(PAGES.GALLERY); router.push(PAGES.GALLERY);
} catch (e) { } catch (e) {
logError(e); logError(e, 'user entered a wrong password');
setFieldError('passphrase', constants.INCORRECT_PASSPHRASE); setFieldError('passphrase', constants.INCORRECT_PASSPHRASE);
} }
} catch (e) { } catch (e) {
@ -86,7 +86,6 @@ export default function Credentials() {
'passphrase', 'passphrase',
`${constants.UNKNOWN_ERROR} ${e.message}` `${constants.UNKNOWN_ERROR} ${e.message}`
); );
console.error('failed to verifyPassphrase ', e.message);
} }
}; };

View file

@ -63,7 +63,7 @@ export default function Recover() {
setData(LS_KEYS.SHOW_BACK_BUTTON, { value: false }); setData(LS_KEYS.SHOW_BACK_BUTTON, { value: false });
router.push(PAGES.CHANGE_PASSWORD); router.push(PAGES.CHANGE_PASSWORD);
} catch (e) { } catch (e) {
logError(e); logError(e, 'password recovery failed');
setFieldError('passphrase', constants.INCORRECT_RECOVERY_KEY); setFieldError('passphrase', constants.INCORRECT_RECOVERY_KEY);
} }
}; };

View file

@ -65,7 +65,7 @@ export default function Recover() {
}); });
router.push(PAGES.CREDENTIALS); router.push(PAGES.CREDENTIALS);
} catch (e) { } catch (e) {
logError(e); logError(e, 'two factor recovery failed');
setFieldError('passphrase', constants.INCORRECT_RECOVERY_KEY); setFieldError('passphrase', constants.INCORRECT_RECOVERY_KEY);
} }
}; };

View file

@ -107,7 +107,7 @@ class billingService {
const { subscription } = response.data; const { subscription } = response.data;
setData(LS_KEYS.SUBSCRIPTION, subscription); setData(LS_KEYS.SUBSCRIPTION, subscription);
} catch (e) { } catch (e) {
logError(e); logError(e, 'subscription cancel failed');
throw e; throw e;
} }
} }
@ -125,7 +125,7 @@ class billingService {
const { subscription } = response.data; const { subscription } = response.data;
setData(LS_KEYS.SUBSCRIPTION, subscription); setData(LS_KEYS.SUBSCRIPTION, subscription);
} catch (e) { } catch (e) {
logError(e); logError(e, 'failed to activate subscription');
throw e; throw e;
} }
} }

View file

@ -114,10 +114,9 @@ const getCollections = async (
key key
); );
} catch (e) { } catch (e) {
logError( logError(e, `decryption failed for collection`, {
e, collectionID: collection.id,
`decryption failed for collection with id=${collection.id}` });
);
} }
return collectionWithSecrets; return collectionWithSecrets;
} }

View file

@ -227,7 +227,7 @@ class ExportService {
} }
return { paused: false }; return { paused: false };
} catch (e) { } catch (e) {
logError(e); logError(e, 'export failed ');
} }
} }
async addFilesQueuedRecord(folder: string, files: File[]) { async addFilesQueuedRecord(folder: string, files: File[]) {

View file

@ -111,7 +111,7 @@ export async function parseMetadataJSON(receivedFile: globalThis.File) {
} }
return { title, parsedMetaDataJSON } as ParsedMetaDataJSONWithTitle; return { title, parsedMetaDataJSON } as ParsedMetaDataJSONWithTitle;
} catch (e) { } catch (e) {
logError(e); logError(e, 'parseMetadataJSON failed');
// ignore // ignore
} }
} }

View file

@ -1,5 +1,5 @@
import { FILE_TYPE } from 'services/fileService'; import { FILE_TYPE } from 'services/fileService';
import { CustomError } from 'utils/common/errorUtil'; import { CustomError, errorWithContext } from 'utils/common/errorUtil';
import { convertHEIC2JPEG } from 'utils/file'; import { convertHEIC2JPEG } from 'utils/file';
import { logError } from 'utils/sentry'; import { logError } from 'utils/sentry';
import { BLACK_THUMBNAIL_BASE64 } from '../../../public/images/black-thumbnail-b64'; import { BLACK_THUMBNAIL_BASE64 } from '../../../public/images/black-thumbnail-b64';
@ -85,13 +85,11 @@ export async function generateImageThumbnail(
clearTimeout(timeout); clearTimeout(timeout);
resolve(null); resolve(null);
} catch (e) { } catch (e) {
reject(e); const err = errorWithContext(
logError(e); e,
reject(
Error(
`${CustomError.THUMBNAIL_GENERATION_FAILED} err: ${e}` `${CustomError.THUMBNAIL_GENERATION_FAILED} err: ${e}`
)
); );
reject(err);
} }
}; };
timeout = setTimeout( timeout = setTimeout(
@ -142,7 +140,7 @@ export async function generateVideoThumbnail(file: globalThis.File) {
const err = Error( const err = Error(
`${CustomError.THUMBNAIL_GENERATION_FAILED} err: ${e}` `${CustomError.THUMBNAIL_GENERATION_FAILED} err: ${e}`
); );
logError(err); logError(e, CustomError.THUMBNAIL_GENERATION_FAILED);
reject(err); reject(err);
} }
}); });

View file

@ -123,7 +123,7 @@ class UploadHttpClient {
); );
if (!resp?.headers?.etag) { if (!resp?.headers?.etag) {
const err = Error(CustomError.ETAG_MISSING); const err = Error(CustomError.ETAG_MISSING);
logError(err); logError(err, 'putFile in parts failed');
throw err; throw err;
} }
return resp; return resp;

View file

@ -230,7 +230,7 @@ function handleFailureReason(
setDialogMessage: SetDialogMessage, setDialogMessage: SetDialogMessage,
setLoading: SetLoading setLoading: SetLoading
): void { ): void {
logError(Error(`subscription purchase failed with reason- ${reason}`)); logError(Error(reason), 'subscription purchase failed');
switch (reason) { switch (reason) {
case FAILURE_REASON.CANCELED: case FAILURE_REASON.CANCELED:
setDialogMessage({ setDialogMessage({

View file

@ -4,7 +4,7 @@ import { getUserAnonymizedID } from 'utils/user';
export const logError = ( export const logError = (
e: any, e: any,
msg?: string, msg: string,
info?: Record<string, unknown> info?: Record<string, unknown>
) => { ) => {
const err = errorWithContext(e, msg); const err = errorWithContext(e, msg);