@@ 109-131 (lines=23) @@ | ||
106 | * |
|
107 | * @throws \RuntimeException if cannot create the container |
|
108 | */ |
|
109 | public function createContainer($containerName, CreateContainerOptions $options = null) |
|
110 | { |
|
111 | $this->init(); |
|
112 | ||
113 | if (null === $options) { |
|
114 | $options = $this->getCreateContainerOptions(); |
|
115 | } |
|
116 | ||
117 | try { |
|
118 | $this->blobProxy->createContainer($containerName, $options); |
|
119 | } catch (ServiceException $e) { |
|
120 | $errorCode = $this->getErrorCodeFromServiceException($e); |
|
121 | ||
122 | if ($errorCode !== self::ERROR_CONTAINER_ALREADY_EXISTS) { |
|
123 | throw new \RuntimeException(sprintf( |
|
124 | 'Failed to create the configured container "%s": %s (%s).', |
|
125 | $containerName, |
|
126 | $e->getErrorText(), |
|
127 | $errorCode |
|
128 | )); |
|
129 | } |
|
130 | } |
|
131 | } |
|
132 | ||
133 | /** |
|
134 | * Deletes a container. |
|
@@ 141-159 (lines=19) @@ | ||
138 | * |
|
139 | * @throws \RuntimeException if cannot delete the container |
|
140 | */ |
|
141 | public function deleteContainer($containerName, DeleteContainerOptions $options = null) |
|
142 | { |
|
143 | $this->init(); |
|
144 | ||
145 | try { |
|
146 | $this->blobProxy->deleteContainer($containerName, $options); |
|
147 | } catch (ServiceException $e) { |
|
148 | $errorCode = $this->getErrorCodeFromServiceException($e); |
|
149 | ||
150 | if ($errorCode !== self::ERROR_CONTAINER_NOT_FOUND) { |
|
151 | throw new \RuntimeException(sprintf( |
|
152 | 'Failed to delete the configured container "%s": %s (%s).', |
|
153 | $containerName, |
|
154 | $e->getErrorText(), |
|
155 | $errorCode |
|
156 | ), $e->getCode()); |
|
157 | } |
|
158 | } |
|
159 | } |
|
160 | ||
161 | /** |
|
162 | * {@inheritdoc} |