Skip to content
Merged
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
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fumifier",
"version": "2.2.1",
"version": "2.2.2",
"description": "Fumifier is the core FLASH DSL engine inside FUME - It parses, compiles and executes FHIR related transformation logic expressed with FUME's specialized syntax (FLASH) and applies it to JSON data structures.",
"author": "Outburn Ltd.",
"main": "./dist/index.cjs",
Expand Down
3 changes: 3 additions & 0 deletions src/utils/diagnostics.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ export function push(env, entry) {

// sanitize entry: remove stack from collected diagnostics
const rest = { ...(entry || {}) };
if (entry instanceof Error || (typeof entry?.message === 'string' && !Object.prototype.hasOwnProperty.call(rest, 'message'))) {
rest.message = entry.message;
}
if (Object.prototype.hasOwnProperty.call(rest, 'stack')) delete rest.stack;

// dedupe: ensure we don't collect identical diagnostics multiple times
Expand Down
20 changes: 20 additions & 0 deletions test/use-fhir-server.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,26 @@ describe('$useFhirServer', function() {
}
});

it('preserves the populated message in evaluateVerbose diagnostics for resolver failures', async function() {
const expr = await fumifier("$useFhirServer('public-hap')", {
connectionResolver: (target) => {
throw new Error(`Unknown FHIR connection name: "${target}"`);
}
});

const report = await expr.evaluateVerbose({});

expect(report.ok).to.equal(false);
expect(report.status).to.equal(422);
expect(report.diagnostics.error).to.have.lengthOf(1);
expect(report.diagnostics.error[0]).to.include({
code: 'D3201',
token: 'useFhirServer',
message: 'Failed to switch FHIR server to "public-hap": Unknown FHIR connection name: "public-hap"',
sourceMessage: 'Unknown FHIR connection name: "public-hap"'
});
});

it('keeps $translateCode on terminology runtime after switching FHIR servers', async function() {
const defaultClient = createClient(1);
const resolverCalls = [];
Expand Down
Loading