Skip to content
Snippets Groups Projects
Commit 4bfc8450 authored by Etienne LOUPIAS's avatar Etienne LOUPIAS
Browse files

chore(structure): add error message if ctm territories definition not found

parent 7e1de1c9
No related branches found
No related tags found
1 merge request!404V3.1.0 (sans impression)
import { HttpService } from '@nestjs/axios';
import { Injectable, Logger } from '@nestjs/common';
import { HttpException, HttpStatus, Injectable, Logger } from '@nestjs/common';
import { InjectModel } from '@nestjs/mongoose';
import { Model } from 'mongoose';
import { lastValueFrom } from 'rxjs';
......@@ -27,6 +27,13 @@ export class CategoriesService {
public async findCtmByInseeCode(inseeCode: string): Promise<Module> {
const ctm = await this.findOneComplete('ctm');
if (!ctm) {
this.logger.error(`CTM territories definition not found. For local dev, run init-ctm-territories.js script.`);
throw new HttpException(
`CTM territories definition not found in database. For local dev, run init-ctm-territories.js script.`,
HttpStatus.INTERNAL_SERVER_ERROR
);
}
return ctm.modules.find((ctm) => ctm.communes.includes(inseeCode));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment