Skip to content

Commit

Permalink
refactor(api) move YamlParsingError to src
Browse files Browse the repository at this point in the history
  • Loading branch information
yaf committed Jul 19, 2024
1 parent ef07f6d commit 37512d2
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions api/lib/application/error-manager.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { UnableToAttachChildOrganizationToParentOrganizationError } from '../../src/organizational-entities/domain/errors.js';
import { UserNotFoundError } from '../../src/shared/domain/errors.js';
import { UserNotFoundError, YamlParsingError } from '../../src/shared/domain/errors.js';
import * as DomainErrors from '../domain/errors.js';
import * as errorSerializer from '../infrastructure/serializers/jsonapi/error-serializer.js';
import { HttpErrors } from './http-errors.js';
Expand Down Expand Up @@ -256,7 +256,7 @@ function _mapToHttpError(error) {
return new HttpErrors.BadRequestError(error.message);
}

if (error instanceof DomainErrors.YamlParsingError) {
if (error instanceof YamlParsingError) {
return new HttpErrors.UnprocessableEntityError(error.message, error.code, error.meta);
}

Expand Down
7 changes: 0 additions & 7 deletions api/lib/domain/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -732,12 +732,6 @@ class InvalidIdentityProviderError extends DomainError {
}
}

class YamlParsingError extends DomainError {
constructor(message = "Une erreur s'est produite lors de l'interprétation des réponses.") {
super(message);
}
}

class InvalidExternalAPIResponseError extends DomainError {
constructor(message = "L'API externe a renvoyé une réponse incorrecte.") {
super(message);
Expand Down Expand Up @@ -948,5 +942,4 @@ export {
UserOrgaSettingsCreationError,
UserShouldNotBeReconciledOnAnotherAccountError,
WrongDateFormatError,
YamlParsingError,
};
2 changes: 1 addition & 1 deletion api/lib/domain/services/solution-service-qrocm-dep.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import jsYaml from 'js-yaml';

import { YamlParsingError } from '../../../src/shared/domain/errors.js';
import { AnswerStatus } from '../../../src/shared/domain/models/AnswerStatus.js';
import { YamlParsingError } from '../../domain/errors.js';
import { getEnabledTreatments, useLevenshteinRatio } from './services-utils.js';
import { validateAnswer } from './string-comparison-service.js';
import { applyPreTreatments, applyTreatments } from './validation-treatments.js';
Expand Down
2 changes: 1 addition & 1 deletion api/lib/domain/services/solution-service-qrocm-ind.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import levenshtein from 'fast-levenshtein';
import jsYaml from 'js-yaml';

import { LEVENSHTEIN_DISTANCE_MAX_RATE } from '../../../src/shared/domain/constants.js';
import { YamlParsingError } from '../../../src/shared/domain/errors.js';
import { AnswerStatus } from '../../../src/shared/domain/models/AnswerStatus.js';
import { _ } from '../../../src/shared/infrastructure/utils/lodash-utils.js';
import { logger } from '../../../src/shared/infrastructure/utils/logger.js';
import { YamlParsingError } from '../../domain/errors.js';
import { useLevenshteinRatio } from './services-utils.js';
import { applyPreTreatments, applyTreatments } from './validation-treatments.js';

Expand Down
7 changes: 7 additions & 0 deletions api/src/shared/domain/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,12 @@ class UserNotFoundError extends NotFoundError {
}
}

class YamlParsingError extends DomainError {
constructor(message = "Une erreur s'est produite lors de l'interprétation des réponses.") {
super(message);
}
}

export {
AlreadyExistingEntityError,
AlreadyRegisteredEmailError,
Expand Down Expand Up @@ -392,4 +398,5 @@ export {
UserNotAuthorizedToUpdateEmailError,
UserNotAuthorizedToUpdatePasswordError,
UserNotFoundError,
YamlParsingError,
};
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { YamlParsingError } from '../../../../lib/domain/errors.js';
import {
getCorrection,
getCorrectionDetails,
match,
} from '../../../../lib/domain/services/solution-service-qrocm-dep.js';
import { YamlParsingError } from '../../../../src/shared/domain/errors.js';
import { AnswerStatus } from '../../../../src/shared/domain/models/AnswerStatus.js';
import { catchErr, expect, sinon } from '../../../test-helper.js';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { YamlParsingError } from '../../../../lib/domain/errors.js';
import * as service from '../../../../lib/domain/services/solution-service-qrocm-ind.js';
import { YamlParsingError } from '../../../../src/shared/domain/errors.js';
import { AnswerStatus } from '../../../../src/shared/domain/models/AnswerStatus.js';
import { catchErr, expect } from '../../../test-helper.js';

Expand Down

0 comments on commit 37512d2

Please sign in to comment.