Creates a new exception for the given value type.
public static forType ( string $type, Webmozart\KeyValueStore\Api\KeyValueStore $store, integer $code, Exception $cause = null ) : static | ||
$type | string | The name of the unsupported type. |
$store | Webmozart\KeyValueStore\Api\KeyValueStore | The store that does not support the type. |
$code | integer | The exception code. |
$cause | Exception | The exception that caused this exception. |
Результат | static | The new exception. |
/** * {@inheritdoc} */ public function set($key, $value) { KeyUtil::validate($key); $serialized = $this->serialize->__invoke($value); try { $this->collection->replaceOne(array('_id' => $key), array('_id' => $key, 'value' => $serialized), array('upsert' => true)); } catch (UnexpectedValueException $e) { throw UnsupportedValueException::forType('binary', $this, 0, $e); } catch (Exception $e) { throw WriteException::forException($e); } }
private function save($data) { try { $this->encoder->encodeFile($data, $this->path); } catch (EncodingFailedException $e) { if (JSON_ERROR_UTF8 === $e->getCode()) { throw UnsupportedValueException::forType('binary', $this); } throw new WriteException($e->getMessage(), 0, $e); } catch (IOException $e) { throw new WriteException($e->getMessage(), 0, $e); } }