blob: c2edc0d050e481f87fb3d174e8b135b7a824c8ab (
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
41
42
43
|
// Copyright 2014 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/push_messaging/push_error.h"
#include "third_party/blink/renderer/core/dom/dom_exception.h"
#include "third_party/blink/renderer/platform/heap/heap.h"
#include "third_party/blink/renderer/platform/wtf/assertions.h"
namespace blink {
DOMException* PushError::CreateException(mojom::PushErrorType error,
const String& message) {
switch (error) {
case mojom::PushErrorType::ABORT:
return MakeGarbageCollected<DOMException>(DOMExceptionCode::kAbortError,
message);
case mojom::PushErrorType::INVALID_STATE:
return MakeGarbageCollected<DOMException>(
DOMExceptionCode::kInvalidStateError, message);
case mojom::PushErrorType::NETWORK:
return MakeGarbageCollected<DOMException>(DOMExceptionCode::kNetworkError,
message);
case mojom::PushErrorType::NONE:
NOTREACHED();
return MakeGarbageCollected<DOMException>(DOMExceptionCode::kUnknownError,
message);
case mojom::PushErrorType::NOT_ALLOWED:
return MakeGarbageCollected<DOMException>(
DOMExceptionCode::kNotAllowedError, message);
case mojom::PushErrorType::NOT_FOUND:
return MakeGarbageCollected<DOMException>(
DOMExceptionCode::kNotFoundError, message);
case mojom::PushErrorType::NOT_SUPPORTED:
return MakeGarbageCollected<DOMException>(
DOMExceptionCode::kNotSupportedError, message);
}
NOTREACHED();
return MakeGarbageCollected<DOMException>(DOMExceptionCode::kUnknownError);
}
} // namespace blink
|