Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/MN-596/photocapture-error-handling #846

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ export function usePhotoCaptureErrorLabel(
if (captureError.name === MonkNetworkError.INSUFFICIENT_AUTHORIZATION) {
return t('photo.hud.error.insufficientAuth');
}
if (captureError.name === MonkNetworkError.RESOURCE_NOT_FOUND) {
return t('photo.hud.error.resourceNotFound');
}
if (captureError.name === MonkNetworkError.INVALID_ARGUMENT) {
return t('photo.hud.error.invalidArgument');
}
}

if (captureError) {
Expand All @@ -83,6 +89,8 @@ export function useRetry({
MonkNetworkError.INVALID_TOKEN,
MonkNetworkError.EXPIRED_TOKEN,
MonkNetworkError.INSUFFICIENT_AUTHORIZATION,
MonkNetworkError.RESOURCE_NOT_FOUND,
MonkNetworkError.INVALID_ARGUMENT,
].includes(captureError.name as MonkNetworkError)
) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,27 +80,29 @@ export function useAdaptiveCameraConfig({

const onUploadTimeout = useCallback(() => lowerMaxImageQuality(), []);

const config = {
quality: initialCameraConfig.quality ?? DEFAULT_CAMERA_CONFIG.quality,
resolution: initialCameraConfig.resolution ?? DEFAULT_CAMERA_CONFIG.resolution,
format: initialCameraConfig.format ?? DEFAULT_CAMERA_CONFIG.format,
allowImageUpscaling:
initialCameraConfig.allowImageUpscaling ?? DEFAULT_CAMERA_CONFIG.allowImageUpscaling,
};

const adaptiveCameraConfig: Required<CameraConfig> = useMemo(() => {
const config = {
quality: initialCameraConfig.quality ?? DEFAULT_CAMERA_CONFIG.quality,
resolution: initialCameraConfig.resolution ?? DEFAULT_CAMERA_CONFIG.resolution,
format: initialCameraConfig.format ?? DEFAULT_CAMERA_CONFIG.format,
allowImageUpscaling:
initialCameraConfig.allowImageUpscaling ?? DEFAULT_CAMERA_CONFIG.allowImageUpscaling,
};
const adaptiveConfig = {
quality: Math.min(maxQuality, config.quality),
resolution: getLowestResolutionBetween(maxResolution, config.resolution),
format: initialCameraConfig.format ?? config.format,
allowImageUpscaling: isImageUpscalingAllowed && config.allowImageUpscaling,
};
return useAdaptiveImageQuality ? adaptiveConfig : config;
if (useAdaptiveImageQuality) {
return adaptiveConfig;
}
return config;
}, [
config.quality,
config.resolution,
config.format,
config.allowImageUpscaling,
initialCameraConfig.quality,
initialCameraConfig.resolution,
initialCameraConfig.format,
initialCameraConfig.allowImageUpscaling,
maxQuality,
maxResolution,
isImageUpscalingAllowed,
Expand Down
4 changes: 3 additions & 1 deletion packages/inspection-capture-web/src/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
"invalidToken": "Das verwendete Authentifizierungstoken ist ungültig.",
"expiredToken": "Das verwendete Authentifizierungstoken ist abgelaufen.",
"insufficientAuth": "Sie haben nicht die erforderlichen Berechtigungen, um diese Aktion durchzuführen.",
"inspectionLoading": "Beim Laden der Inspektion ist ein Fehler aufgetreten. Bitte versuchen Sie es in Kürze erneut oder kontaktieren Sie den Support mit der folgenden Inspektions-ID:"
"inspectionLoading": "Beim Laden der Inspektion ist ein Fehler aufgetreten. Bitte versuchen Sie es in Kürze erneut oder kontaktieren Sie den Support mit der folgenden Inspektions-ID:",
"resourceNotFound": "Inspektions-ID nicht gefunden.",
"invalidArgument": "Entwicklungsfehler: Eines oder mehrere der angegebenen Argumente sind ungültig."
},
"closeConfirm": {
"message": "Sind Sie sicher, dass Sie das Erfassungstool schließen wollen?",
Expand Down
4 changes: 3 additions & 1 deletion packages/inspection-capture-web/src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
"invalidToken": "The authentication token used is invalid.",
"expiredToken": "The authentication token used is expired.",
"insufficientAuth": "You do not have the required autorizations to perform this action.",
"inspectionLoading": "An error occurred during the loading of the inspection. Please try again in a few minutes or contact the support with the following inspection id :"
"inspectionLoading": "An error occurred during the loading of the inspection. Please try again in a few minutes or contact the support with the following inspection id :",
"resourceNotFound": "Inspection ID not found.",
"invalidArgument": "Dev Error: One or more of the provided arguments are invalid."
},
"closeConfirm": {
"message": "Are you sure you want to close the capture tool?",
Expand Down
9 changes: 7 additions & 2 deletions packages/inspection-capture-web/src/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,20 @@
"damagedPartCounter": "1 / 2 • Pièce endommagée",
"closeupPictureCounter": "2 / 2 • Dégât en gros plan",
"infoBtn": "Placer le viseur sur la pièce endommagée puis enclencher le bouton capture de la photo",
"infoCloseup": "Prendre une photo en gros plan du dégât"
"infoCloseup": "Veuillez prendre une photo en gros plan du dégât",
"selectParts": "Veuillez sélectionner les pièces endommagées",
"accept": "Accepter",
"cancel": "Annuler"
},
"error": {
"retry": "Réessayer",
"missingTasks": "L'inspection fournie ne possède pas certaines tâches requises par le module de capture actuel.",
"invalidToken": "Le token d'authentification utilisé est invalide.",
"expiredToken": "Le token d'authentification utilisé est expiré.",
"insufficientAuth": "Vous n'avez pas les autorisations nécessaires pour effectuer cette action.",
"inspectionLoading": "Une erreur est survenue lors du chargement de l'inspection. Veuillez réessayer dans quelques instants ou contacter le support avec l'identifiant d'inspection suivant :"
"inspectionLoading": "Une erreur est survenue lors du chargement de l'inspection. Veuillez réessayer dans quelques instants ou contacter le support avec l'identifiant d'inspection suivant :",
"resourceNotFound": "ID d'inspection introuvable.",
"invalidArgument": "Erreur de développement : un ou plusieurs des arguments fournis ne sont pas valides."
},
"closeConfirm": {
"message": "Êtes-vous sûr(e) de vouloir fermer l'outil de capture ?",
Expand Down
9 changes: 7 additions & 2 deletions packages/inspection-capture-web/src/translations/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,20 @@
"damagedPartCounter": "1 / 2 • Beschadigd onderdeel",
"closeupPictureCounter": "2 / 2 • Closeup foto",
"infoBtn": "Richt de markering op het beschadigde onderdeel en tik vervolgens op de sluitertknop",
"infoCloseup": "Neem een closeup foto van de schade"
"infoCloseup": "Neem een closeup foto van de schade",
"selectParts": "Selecteer de onderdelen waar je schade zit",
"accept": "Accepteren",
"cancel": "Annuleren"
},
"error": {
"retry": "Opnieuw proberen",
"missingTasks": "De inspectie die is geleverd, mist enkele taken die vereist zijn door de huidige capture module.",
"invalidToken": "Het gebruikte authenticatietoken is ongeldig.",
"expiredToken": "Het gebruikte authenticatietoken is verlopen.",
"insufficientAuth": "U heeft niet de vereiste autorisaties om deze actie uit te voeren.",
"inspectionLoading": "Er is een fout opgetreden tijdens het laden van de inspectie. Probeer het later nog eens of neem contact op met de ondersteuning met het volgende inspectie-id :"
"inspectionLoading": "Er is een fout opgetreden tijdens het laden van de inspectie. Probeer het later nog eens of neem contact op met de ondersteuning met het volgende inspectie-id :",
"resourceNotFound": "Inspectie-ID niet gevonden.",
"invalidArgument": "Ontwikkelaarsfout: een of meer van de opgegeven argumenten zijn ongeldig."
},
"closeConfirm": {
"message": "Weet je zeker dat je de capture tool wilt sluiten?",
Expand Down
8 changes: 8 additions & 0 deletions packages/network/src/api/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ export enum MonkNetworkError {
* authorization to perform the request.
*/
INSUFFICIENT_AUTHORIZATION = 'InsufficientAuthorization',
/**
* The resource requested was not found.
*/
RESOURCE_NOT_FOUND = 'ResourceNotFoundError',
/**
* The argument provided in the request is invalid.
*/
INVALID_ARGUMENT = 'InvalidArgumentError',
}

function getErrorMessage(name: string): string | null {
Expand Down