diff --git a/extensions/cornerstone/src/initWADOImageLoader.js b/extensions/cornerstone/src/initWADOImageLoader.js index dea4fbff9..d9a7def69 100644 --- a/extensions/cornerstone/src/initWADOImageLoader.js +++ b/extensions/cornerstone/src/initWADOImageLoader.js @@ -1,6 +1,7 @@ import cornerstone from 'cornerstone-core'; import cornerstoneWADOImageLoader from 'cornerstone-wado-image-loader'; import dicomParser from 'dicom-parser'; +import { errorHandler } from '@ohif/core' let initialized = false; @@ -35,6 +36,9 @@ export default function initWADOImageLoader(UserAuthenticationService) { xhr.setRequestHeader('Authorization', headers.Authorization); } }, + errorInterceptor: error => { + errorHandler.getHTTPErrorHandler(error) + }, }); initWebWorkers(); diff --git a/extensions/default/src/DicomWebDataSource/index.js b/extensions/default/src/DicomWebDataSource/index.js index 8e7d217ef..214f56a11 100644 --- a/extensions/default/src/DicomWebDataSource/index.js +++ b/extensions/default/src/DicomWebDataSource/index.js @@ -7,7 +7,7 @@ import { processSeriesResults, } from './qido.js'; import dcm4cheeReject from './dcm4cheeReject'; -import { DicomMetadataStore, IWebApiDataSource, utils } from '@ohif/core'; +import { DicomMetadataStore, IWebApiDataSource, utils, errorHandler } from '@ohif/core'; import getImageId from './utils/getImageId'; import dcmjs from 'dcmjs'; @@ -52,11 +52,14 @@ function createDicomWebApi(dicomWebConfig, UserAuthenticationService) { const qidoConfig = { url: qidoRoot, headers: UserAuthenticationService.getAuthorizationHeader(), + errorInterceptor: errorHandler.getHTTPErrorHandler(), + }; const wadoConfig = { url: wadoRoot, headers: UserAuthenticationService.getAuthorizationHeader(), + errorInterceptor: errorHandler.getHTTPErrorHandler(), }; // TODO -> Two clients sucks, but its better than 1000. diff --git a/platform/viewer/public/config/default.js b/platform/viewer/public/config/default.js index eb828a5d5..cd9b97d6c 100644 --- a/platform/viewer/public/config/default.js +++ b/platform/viewer/public/config/default.js @@ -39,6 +39,14 @@ window.config = { configuration: {}, }, ], + httpErrorHandler: error => { + // This is 429 when rejected from the public idc sandbox too often. + console.warn(error.status); + + // Could use services manager here to bring up a dialog/modal if needed. + console.warn('test, navigate to https://ohif.org/'); + window.location = 'https://ohif.org/'; + }, // whiteLabeling: { // /* Optional: Should return a React component to be rendered in the "Logo" section of the application's Top Navigation bar */ // createLogoComponentFn: function (React) { diff --git a/platform/viewer/src/appInit.js b/platform/viewer/src/appInit.js index fb110b0fe..8015ca3eb 100644 --- a/platform/viewer/src/appInit.js +++ b/platform/viewer/src/appInit.js @@ -14,6 +14,7 @@ import { HangingProtocolService, CineService, UserAuthenticationService, + errorHandler // utils, } from '@ohif/core'; @@ -62,6 +63,12 @@ function appInit(appConfigOrFunc, defaultExtensions) { UserAuthenticationService, ]); + errorHandler.getHTTPErrorHandler = () => { + if (typeof appConfig.httpErrorHandler === 'function') { + return appConfig.httpErrorHandler; + } + }; + /** * Example: [ext1, ext2, ext3] * Example2: [[ext1, config], ext2, [ext3, config]]