Skip to content

Commit

Permalink
rockcarver/frodo-cli#192: Backend support for better error handling a…
Browse files Browse the repository at this point in the history
…nd reporting in frodo-cli
  • Loading branch information
vscheuber committed Jan 27, 2023
1 parent 0dec4a3 commit f16fde5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- rockcarver/frodo-cli#192: Backend support for better error handling and reporting in frodo-cli

## [0.18.2] - 2023-01-25

### Added
Expand Down
22 changes: 17 additions & 5 deletions src/ops/Saml2Ops.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ async function exportDependencies(providerData, fileData) {
if (attrMapperScriptId && attrMapperScriptId !== '[Empty]') {
const scriptData = await getScript(attrMapperScriptId);
scriptData.script = convertBase64TextToArray(scriptData.script);
// eslint-disable-next-line no-param-reassign
fileData.script[attrMapperScriptId] = scriptData;
}
const idpAdapterScriptId = _.get(providerData, [
Expand All @@ -123,11 +122,16 @@ async function exportDependencies(providerData, fileData) {
if (idpAdapterScriptId && idpAdapterScriptId !== '[Empty]') {
const scriptData = await getScript(idpAdapterScriptId);
scriptData.script = convertBase64TextToArray(scriptData.script);
// eslint-disable-next-line no-param-reassign
fileData.script[idpAdapterScriptId] = scriptData;
}
const metaDataResponse = await getProviderMetadata(providerData.entityId);
// eslint-disable-next-line no-param-reassign
if (!metaDataResponse) {
throw new Error(
`Unable to obtain metadata from ${getProviderMetadataUrl(
providerData.entityId
)}`
);
}
fileData.saml.metadata[providerData._id] = convertBase64UrlTextToArray(
encodeBase64Url(metaDataResponse)
);
Expand Down Expand Up @@ -225,7 +229,11 @@ export async function exportSaml2Provider(
const id = stub._id;
const providerData = await getProviderByLocationAndId(location, id);
exportData.saml[stub.location][providerData._id] = providerData;
await exportDependencies(providerData, exportData);
try {
await exportDependencies(providerData, exportData);
} catch (error) {
printMessage(error.message, 'error');
}
debugMessage(`Saml2Ops.exportSaml2Provider: end [entityId=${entityId}]`);
return exportData;
}
Expand All @@ -242,7 +250,11 @@ export async function exportSaml2Providers(): Promise<Saml2ExportInterface> {
stub.location,
stub._id
);
await exportDependencies(providerData, fileData);
try {
await exportDependencies(providerData, fileData);
} catch (error) {
printMessage(error, 'error');
}
fileData.saml[stub.location][providerData._id] = providerData;
}
return fileData;
Expand Down

0 comments on commit f16fde5

Please sign in to comment.