Skip to content

Commit

Permalink
fix: return undefined when structure definition isn't found (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
mechanik-daniel authored Jun 5, 2024
1 parent de116d9 commit 69eb304
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/helpers/jsonataFunctions/getStructureDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ export const getStructureDefinitionPath = (definitionId: string): any => {
export const getStructureDefinition = (definitionId: string): any => {
try {
const path: string = getStructureDefinitionPath(definitionId);

const fullDef = JSON.parse(fs.readFileSync(path).toString()); // load file
return fullDef;
if (path) {
const fullDef = JSON.parse(fs.readFileSync(path).toString()); // load file
return fullDef;
} else return undefined;
} catch (e) {
return thrower.throwParseError(`A Problem occured while getting the structure definition of '${definitionId}'. The error is: ${e}`);
}
Expand Down

0 comments on commit 69eb304

Please sign in to comment.