import MiddlewareError from "../generated/errors/MiddlewareError" ; import { jsonToXML } from "../generated/utils/xml" ; export class extends MiddlewareError export default class StorageError extends MiddlewareError { public readonly storageErrorCode : string ; public readonly storageErrorMessage : string ; public readonly storageRequestID : string ; param { number } statusCode param { string } storageErrorCode param { string } storageErrorMessage param { string } storageRequestID param { { [ key : string ] : string } } storageAdditionalErrorMessages memberof constructor ( statusCode , storageErrorCode , storageErrorMessage , storageRequestID , storageAdditionalErrorMessages = { } ) { const bodyInJSON = { Code : storageErrorCode , Message : `${ storageErrorMessage }\nRequestId:${ storageRequestID }\nTime:${ new Date ( ) . toISOString ( ) }` } ; for ( const key in storageAdditionalErrorMessages ) { if ( storageAdditionalErrorMessages . hasOwnProperty ( key ) ) { const element = storageAdditionalErrorMessages [ key ] ; bodyInJSON [ key ] = element ; } } const bodyInXML = jsonToXML ( { Error : bodyInJSON } ) ; super ( statusCode , storageErrorMessage , storageErrorMessage , { "x-ms-error-code" : storageErrorCode , "x-ms-request-id" : storageRequestID } , bodyInXML , "application/xml" ) ; this . name = "StorageError" ; this . storageErrorCode = storageErrorCode ; this . storageErrorMessage = storageErrorMessage ; this . storageRequestID = storageRequestID ; } }