import StorageError from "./StorageError" ; const defaultID = "DefaultID" ; export class export default class StorageErrorFactory { public static notImplement ( contextID = defaultID ) { return new StorageError ( 500 , "functionNotImplement" , `No function.` , contextID ) ; } public static InternalError ( contextID = defaultID ) { return new StorageError ( 500 , "InternalError" , `The server encountered an internal error. Please retry the request.` , contextID ) ; } public static getInvalidHeaderValue ( contextID = "" , additionalMessages ? ) { if ( additionalMessages === undefined ) { additionalMessages = { } ; } return new StorageError ( 400 , "InvalidHeaderValue" , "The value for one of the HTTP headers is not in the correct format." , contextID , additionalMessages ) ; } public static getInvaidXmlDocument ( contextID = defaultID ) { return new StorageError ( 400 , "InvaidXmlDocument" , `XML specified is not syntactically valid.` , contextID ) ; } public static corsPreflightFailure ( contextID = defaultID , additionalMessages ? ) { return new StorageError ( 403 , "CorsPreflightFailure" , "CORS not enabled or no matching rule found for this request." , contextID , additionalMessages ) ; } public static getInvalidUri ( contextID = defaultID , additionalMessages ? ) { return new StorageError ( 400 , "InvalidUri" , "The specifed resource name contains invalid characters." , contextID ) ; } public static getInvalidAuthenticationInfo ( contextID = defaultID ) { return new StorageError ( 400 , "InvalidAuthenticationInfo" , "Authentication information is not given in the correct format. Check the value of Authorization header." , contextID ) ; } public static getAuthenticationFailed ( contextID = defaultID , authenticationErrorDetail ) { return new StorageError ( 403 , "AuthenticationFailed" , "Server failed to authenticate the request. Make sure the value of the Authorization header is formed correctly including the signature." , contextID , { AuthenticationErrorDetail : authenticationErrorDetail } ) ; } public static getInvalidCorsHeaderValue ( contextID = defaultID , additionalMessages ? ) { return new StorageError ( 400 , "InvalidHeaderValue" , "A required CORS header is not present." , contextID , additionalMessages ) ; } public static getAuthorizationFailure ( contextID = defaultID ) { return new StorageError ( 403 , "AuthorizationFailure" , "Server failed to authenticate the request." + "Make sure the value of the Authorization header is formed correctly including the signature." , contextID ) ; } public static getInvalidOperation ( contextID , message = "" ) { return new StorageError ( 400 , "InvalidOperation" , message , contextID ) ; } public static getAuthorizationSourceIPMismatch ( contextID ) { return new StorageError ( 403 , "AuthorizationSourceIPMismatch" , "This request is not authorized to perform this operation using this source IP {SourceIP}." , contextID ) ; } public static getAuthorizationProtocolMismatch ( contextID ) { return new StorageError ( 403 , "AuthorizationProtocolMismatch" , "This request is not authorized to perform this operation using this protocol." , contextID ) ; } public static getAuthorizationPermissionMismatch ( contextID ) { return new StorageError ( 403 , "AuthorizationPermissionMismatch" , "This request is not authorized to perform this operation using this permission." , contextID ) ; } public static getAuthorizationServiceMismatch ( contextID ) { return new StorageError ( 403 , "AuthorizationServiceMismatch" , "This request is not authorized to perform this operation using this service." , contextID ) ; } public static getAuthorizationResourceTypeMismatch ( contextID ) { return new StorageError ( 403 , "AuthorizationResourceTypeMismatch" , "This request is not authorized to perform this operation using this resource type." , contextID ) ; } public static getInvalidXmlDocument ( contextID = defaultID , additionalMessages ? ) { if ( additionalMessages === undefined ) { additionalMessages = { } ; } return new StorageError ( 400 , "InvalidXmlDocument" , `XML specified is not syntactically valid.` , contextID , additionalMessages ) ; } public static getInvalidQueryParameterValue ( contextID = defaultID , additionalMessages ? ) { if ( additionalMessages === undefined ) { additionalMessages = { } ; } return new StorageError ( 400 , "InvalidQueryParameterValue" , `Value for one of the query parameters specified in the request URI is invalid.` , contextID , additionalMessages ) ; } public static getOutOfRangeQueryParameterValue ( contextID = defaultID , additionalMessages ? ) { if ( additionalMessages === undefined ) { additionalMessages = { } ; } return new StorageError ( 400 , "OutOfRangeQueryParameterValue" , `One of the query parameters specified in the request URI is outside the permissible range.` , contextID , additionalMessages ) ; } public static getRequestBodyTooLarge ( contextID = defaultID , additionalMessages ? ) { return new StorageError ( 413 , "RequestBodyTooLarge" , `The request body is too large and exceeds the maximum permissible limit.` , contextID , additionalMessages ) ; } public static getMessageTooLarge ( contextID = defaultID ) { return new StorageError ( 400 , "MessageTooLarge" , `The message exceeds the maximum allowed size.` , contextID ) ; } public static getPopReceiptMismatch ( contextID = defaultID ) { return new StorageError ( 400 , "PopReceiptMismatch" , `The specified pop receipt did not match the pop receipt for a dequeued message.` , contextID ) ; } public static getMessageNotFound ( contextID = defaultID ) { return new StorageError ( 404 , "MessageNotFound" , `The specified message does not exist.` , contextID ) ; } public static getInvalidResourceName ( contextID = defaultID ) { return new StorageError ( 400 , "InvalidResourceName" , `The specifed resource name contains invalid characters.` , contextID ) ; } public static getOutOfRangeName ( contextID = defaultID ) { return new StorageError ( 400 , "OutOfRangeInput" , `The specified resource name length is not within the permissible limits.` , contextID ) ; } public static getQueueAlreadyExists ( contextID = defaultID ) { return new StorageError ( 409 , "QueueAlreadyExists" , "The specified queue already exists." , contextID ) ; } public static getQueueNotFound ( contextID = defaultID ) { return new StorageError ( 404 , "QueueNotFound" , "The specified queue does not exist." , contextID ) ; } }