関数
GenericErrorStore::populate()
Declares errors
説明 説明
ファイル: src/Errors/GenericErrorStore.php
public function populate() { $genericLogger = new GenericLogger($this->module); $defaultErrors = $this->getErrorCodeMap(); $defaultErrorMessage = $defaultErrors[ErrorStore::INTERNAL_SERVER_ERROR]->message; // Welcart errors $this->addError(new GenericError( self::USCES_DELIVERY_METHOD_INVALID, $this->getConstantNameByValue(self::USCES_DELIVERY_METHOD_INVALID), 400, function ($message) { return $message; }, function ($message) { return $message; } )); $this->addError(new GenericError( self::USCES_CART_IS_EMPTY, $this->getConstantNameByValue(self::USCES_CART_IS_EMPTY), 404, __('Your session has expired. Please re-add the item(s) to your cart and try again.', 'wcexaap'), __('Your session has expired. Please re-add the item(s) to your cart and try again.', 'wcexaap') )); $this->addError(new GenericError( self::USCES_ITEM_OUT_OF_STOCK, $this->getConstantNameByValue(self::USCES_ITEM_OUT_OF_STOCK), 404, function ($message) { return $message; }, function ($message) { return $message; } )); $this->addError(new GenericError( self::USCES_CUSTOM_FIELDS_ERR, $this->getConstantNameByValue(self::USCES_CUSTOM_FIELDS_ERR), 400, function ($message) { return $message; }, function ($message) { return $message; } )); $this->addError(new GenericError( self::USCES_GIFT_SHIPPING_CUSTOMER_ADDRESS_INVALID, $this->getConstantNameByValue(self::USCES_GIFT_SHIPPING_CUSTOMER_ADDRESS_INVALID), 400, function ($message) { return $message; }, function ($message) { return $message; } )); $this->addError(new GenericError( self::USCES_DELIVERY_PREF_INVALID, $this->getConstantNameByValue(self::USCES_DELIVERY_PREF_INVALID), 400, __('The prefecture is not valid.', 'wcexaap'), __('The prefecture is not valid.', 'wcexaap') )); $this->addError(new GenericError( self::USCES_COUNTRY_NOT_TARGET_MARGET, $this->getConstantNameByValue(self::USCES_COUNTRY_NOT_TARGET_MARGET), 400, __('International shipping is unavailable for the country you selected.', 'wcexaap'), __('International shipping is unavailable for the country you selected.', 'wcexaap') )); // Custom errors $this->addError(new GenericError( self::AMAZON_PAY_ORDER_NOT_FOUND, $this->getConstantNameByValue(self::AMAZON_PAY_ORDER_NOT_FOUND), 404, function ($orderId) { // translators: the order ID return sprintf(__('Order ID %d is not an Amazon Pay order', 'wcexaap'), $orderId); }, __('Amazon Pay order not found', 'wcexaap') )); // Amazon Generic errors $this->addError((new GenericError( self::INVALID_PARAMETER_VALUE, $this->getConstantNameByValue(self::INVALID_PARAMETER_VALUE), 400, function ($message) { return $message; }, $defaultErrorMessage ))->setLogger($genericLogger)); $this->addError((new GenericError( self::INVALID_HEADER_VALUE, $this->getConstantNameByValue(self::INVALID_HEADER_VALUE), 400, function ($message) { return $message; }, $defaultErrorMessage ))->setLogger($genericLogger)); $this->addError((new GenericError( self::INVALID_REQUEST_FORMAT, $this->getConstantNameByValue(self::INVALID_REQUEST_FORMAT), 400, function ($message) { return $message; }, $defaultErrorMessage ))->setLogger($genericLogger)); $this->addError((new GenericError( self::INVALID_REQUEST, $this->getConstantNameByValue(self::INVALID_REQUEST), 400, function ($message) { return $message; }, $defaultErrorMessage ))->setLogger($genericLogger)); $this->addError((new GenericError( self::MISSING_HEADER_VALUE, $this->getConstantNameByValue(self::MISSING_HEADER_VALUE), 400, function ($message) { return $message; }, $defaultErrorMessage ))->setLogger($genericLogger)); $this->addError((new GenericError( self::MISSING_PARAMETER_VALUE, $this->getConstantNameByValue(self::MISSING_PARAMETER_VALUE), 400, function ($message) { return $message; }, $defaultErrorMessage ))->setLogger($genericLogger)); $this->addError((new GenericError( self::UNRECOGNIZED_FIELD, $this->getConstantNameByValue(self::UNRECOGNIZED_FIELD), 400, function ($message) { return $message; }, $defaultErrorMessage ))->setLogger($genericLogger)); $this->addError(new GenericError( self::INVALID_SANDBOX_SIMULATION_SPECIFIED, $this->getConstantNameByValue(self::INVALID_SANDBOX_SIMULATION_SPECIFIED), 400, function ($message) { return $message; }, $defaultErrorMessage )); $this->addError((new GenericError( self::DUPLICATE_IDEMPOTENCY_KEY, $this->getConstantNameByValue(self::DUPLICATE_IDEMPOTENCY_KEY), 400, function ($message) { return $message; }, $defaultErrorMessage ))->setLogger($genericLogger)); $this->addError((new GenericError( self::CURRENCY_MISMATCH, $this->getConstantNameByValue(self::CURRENCY_MISMATCH), 400, function ($message) { return $message; }, $defaultErrorMessage ))->setLogger($genericLogger)); $this->addError((new GenericError( self::UNAUTHORIZED_ACCESS, $this->getConstantNameByValue(self::UNAUTHORIZED_ACCESS), 401, function ($message) { return $message; }, $defaultErrorMessage ))->setLogger($genericLogger)); $this->addError((new GenericError( self::INVALID_ACCOUNT_STATUS, $this->getConstantNameByValue(self::INVALID_ACCOUNT_STATUS), 403, function ($message) { return $message; }, $defaultErrorMessage ))->setLogger($genericLogger)); $this->addError((new GenericError( self::INVALID_REQUEST_SIGNATURE, $this->getConstantNameByValue(self::INVALID_REQUEST_SIGNATURE), 403, function ($message) { return $message; }, $defaultErrorMessage ))->setLogger($genericLogger)); $this->addError((new GenericError( self::RESOURCE_NOT_FOUND, $this->getConstantNameByValue(self::RESOURCE_NOT_FOUND), 404, function ($message) { return $message; }, $defaultErrorMessage ))->setLogger($genericLogger)); $this->addError((new GenericError( self::UNSUPPORTED_OPERATION, $this->getConstantNameByValue(self::UNSUPPORTED_OPERATION), 405, function ($message) { return $message; }, $defaultErrorMessage ))->setLogger($genericLogger)); $this->addError((new GenericError( self::REQUEST_NOT_SUPPORTED, $this->getConstantNameByValue(self::REQUEST_NOT_SUPPORTED), 405, function ($message) { return $message; }, $defaultErrorMessage ))->setLogger($genericLogger)); $this->addError((new GenericError( self::TOO_MANY_REQUESTS, $this->getConstantNameByValue(self::TOO_MANY_REQUESTS), 429, function ($message) { return $message; }, $defaultErrorMessage ))->setLogger($genericLogger)); $this->addError((new GenericError( self::AMAZON_INTERNAL_SERVER_ERROR, $this->getConstantNameByValue(self::AMAZON_INTERNAL_SERVER_ERROR), 429, function ($message) { return $message; }, $defaultErrorMessage ))->setLogger($genericLogger)); $this->addError((new GenericError( self::SERVICE_UNAVAILABLE, $this->getConstantNameByValue(self::SERVICE_UNAVAILABLE), 503, function ($message) { return $message; }, __('Amazon is experiencing technical difficulties. Please try again', 'wcexaap') ))->setLogger($genericLogger)); $this->addError((new GenericError( self::AMAZON_PAY_SDK_CLIENT_EXCEPTION, $this->getConstantNameByValue(self::AMAZON_PAY_SDK_CLIENT_EXCEPTION), 400, function ($message) { return $message; }, __('There is a problem with your Amazon Pay merchant settings. Please check your settings and try again.', 'wcexaap') ))->setLogger($genericLogger)); }