Enable use unknown in catch variables (#2784)
* Enable use unknown in catch variables rule * Add type guards in useAuthProvider * Add type cast in FilterErrorsList * Handle error in tasks
This commit is contained in:
parent
443a94834e
commit
b0ba5cc2ab
4 changed files with 17 additions and 4 deletions
|
@ -157,7 +157,11 @@ export function useAuthProvider({
|
||||||
|
|
||||||
return result.data.tokenCreate;
|
return result.data.tokenCreate;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
if (error instanceof ApolloError) {
|
||||||
handleLoginError(error);
|
handleLoginError(error);
|
||||||
|
} else {
|
||||||
|
setErrors(["unknownLoginError"]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -195,7 +199,11 @@ export function useAuthProvider({
|
||||||
|
|
||||||
return result?.data?.externalObtainAccessTokens;
|
return result?.data?.externalObtainAccessTokens;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
if (error instanceof ApolloError) {
|
||||||
handleLoginError(error);
|
handleLoginError(error);
|
||||||
|
} else {
|
||||||
|
setErrors(["unknownLoginError"]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ const FilterErrorsList: React.FC<FilterErrorsListProps> = ({
|
||||||
{ dependencies: dependencies?.join() },
|
{ dependencies: dependencies?.join() },
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
errorTracker.captureException(e);
|
errorTracker.captureException(e as Error);
|
||||||
console.warn("Translation missing for filter error code: ", code);
|
console.warn("Translation missing for filter error code: ", code);
|
||||||
return intl.formatMessage(validationMessages.UNKNOWN_ERROR);
|
return intl.formatMessage(validationMessages.UNKNOWN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,11 @@ export async function handleTask(task: QueuedTask): Promise<TaskStatus> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
if (error instanceof Error) {
|
||||||
task.onError(error);
|
task.onError(error);
|
||||||
|
} else {
|
||||||
|
console.error("Unknown error", error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
"noImplicitThis": true,
|
"noImplicitThis": true,
|
||||||
"alwaysStrict": true,
|
"alwaysStrict": true,
|
||||||
"strictBindCallApply": true,
|
"strictBindCallApply": true,
|
||||||
|
"useUnknownInCatchVariables": true,
|
||||||
"paths": {
|
"paths": {
|
||||||
"@assets/*": ["assets/*"],
|
"@assets/*": ["assets/*"],
|
||||||
"@locale/*": ["locale/*"],
|
"@locale/*": ["locale/*"],
|
||||||
|
|
Loading…
Reference in a new issue