import { isString } from 'util' ; import { injectable } from 'inversify' ; import { isNil } from 'lodash' ; import { notificationErrorNameToErrorMap , scanErrorNameToErrorMap , ScanNotificationErrorCode , ScanNotificationErrorCodes , ScanRunErrorCode , ScanRunErrorCodes , } from 'service-library' ; import { NotificationError , ScanError } from 'storage-documents' ; @ injectable ( ) export class ScanErrorConverter { public getScanRunErrorCode ( scanError ) { if ( isNil ( scanError ) || isString ( scanError ) ) { return ScanRunErrorCodes . internalError ; } return scanErrorNameToErrorMap [ scanError . errorType ] ; } public getScanNotificationErrorCode ( scanNotificationError ) { if ( isString ( scanNotificationError ) ) { return ScanNotificationErrorCodes . InternalError ; } return notificationErrorNameToErrorMap [ scanNotificationError . errorType ] ; } }