summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/modules/cache_storage/cache_storage_error.cc
blob: 2fa64c4c37b8ce4a37f6688a140837b48ab14065 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "third_party/blink/renderer/modules/cache_storage/cache_storage_error.h"

#include "third_party/blink/public/platform/modules/cache_storage/cache_storage.mojom-blink.h"
#include "third_party/blink/renderer/core/dom/dom_exception.h"
#include "third_party/blink/renderer/core/dom/exception_code.h"
#include "third_party/blink/renderer/modules/cache_storage/cache.h"

namespace blink {

DOMException* CacheStorageError::CreateException(
    mojom::CacheStorageError web_error) {
  switch (web_error) {
    case mojom::CacheStorageError::kErrorNotImplemented:
      return DOMException::Create(kNotSupportedError,
                                  "Method is not implemented.");
    case mojom::CacheStorageError::kErrorNotFound:
      return DOMException::Create(kNotFoundError, "Entry was not found.");
    case mojom::CacheStorageError::kErrorExists:
      return DOMException::Create(kInvalidAccessError, "Entry already exists.");
    case mojom::CacheStorageError::kErrorQuotaExceeded:
      return DOMException::Create(kQuotaExceededError, "Quota exceeded.");
    case mojom::CacheStorageError::kErrorCacheNameNotFound:
      return DOMException::Create(kNotFoundError, "Cache was not found.");
    case mojom::CacheStorageError::kErrorQueryTooLarge:
      return DOMException::Create(kAbortError, "Operation too large.");
    case mojom::CacheStorageError::kErrorStorage:
      return DOMException::Create(kUnknownError, "Unexpected internal error.");
    case mojom::CacheStorageError::kSuccess:
      // This function should only be called with an error.
      break;
  }
  NOTREACHED();
  return nullptr;
}

}  // namespace blink