Error Handler on DicomJSON Datastorage

Error Handler when loading studies

I created a custom API to build the DICOM Json manifest used to view a study from: http://ohif.example.com/viewer/dicomjson?url={URL}
This works fine. But I like to handle the error if something has wrong calling the api (i:e Cors error, 408, 401, 429, …)
Reading the doc this can be done by the app-config.js:

window.config = {
 httpErrorHandler: error => {
    // This is 429 when rejected from the public idc sandbox too often.
    console.warn(error.status);
    console.log("ERRORINRESPONSE");

    // Could use services manager here to bring up a dialog/modal if needed.
    console.warn('test, navigate to https://ohif.org/');
  },
...
};

But these console.logs() are not displayed on the console… I get the XHR error (ie Cors error) and Uncaught (in promise)...

Solicitud desde otro origen bloqueada: la política de mismo origen impide leer el recurso remoto en http://ohif.example.com/... (razón: falta la cabecera CORS 'Access-Control-Allow-Origin'). Código de estado: 400.
Uncaught (in promise) TypeError: NetworkError when attempting to fetch resource.

Using OHIF v3.6.0

Is there a way to handle this type of errors and show a notification or a browser alert message?
Thanks you guys!
Sorry about my english!

Welcome to the community @martinonicolas!

I believe this error handler is in turn passed to the DICOMweb client library and that library invokes the callback for various http errors and exceptions. I do not believe it is used for DICOM JSON.

I wonder if something like window.onerror might help you?

Hope this helps.

Hello @martinonicolas Where do you serve the Dicom Json manifest from ? Also, are the dicom files on a local server or on orthanc? I am trying to make this work on my end, but have been unsuccessful so far.

Hi, @ PintoGideon we still use the deprecated dcm4chee-2.18.3, so we develop a RESTful API which connects to the dcm4chee database and produce de corresponding DICOM Json manifest. We use wado in the url param of the manifest to retrieve the dicom image.

Example

{
"studies": [
	{
		"StudyInstanceUID": "??????????????",
		"StudyDate": "AAAAMMDD",
		"StudyTime": "HH:MM:SS",
		"PatientName": "FAMILYNAME^GIVENNAME^^^",
		"PatientID": "ID",
		"AccessionNumber": "1234567",
		"PatientSex": "O",
		"NumInstances": 1,
		"Modalities": "CR",
		"series": [
			{
				"SeriesInstanceUID": "?????????????",
				"SeriesNumber": 1,
				"Modality": "CR",
				"instances": [
					{
						"metadata": {
							"InstanceNumber": 1,
							"SOPClassUID": "????????",
							"Modality": "CR",
							"SOPInstanceUID": "?????????",
							"SeriesInstanceUID": "???????????",
							"StudyInstanceUID": "????????",
							"SeriesDate": "AAAAMMDD",
							"Columns": 512,
							"Rows": 512,
							"PhotometricInterpretation": "MONOCHROME2",
							"BitsAllocated": 8
						},
						"url": "dicomweb:http://<dcm4chee-server-ip>:8080/wado?requestType=WADO&studyUID=?????????????&seriesUID=?????????&objectUID=???????????&contentType=application/dicom&transferSyntax=1.2.840.10008.1.2"
					},
...