blob: 7dc124e71ec5d28de22edc3bcaef949746cd3cbf [file] [log] [blame]
// 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 "modules/presentation/PresentationError.h"
#include "core/dom/ExceptionCode.h"
namespace blink {
DOMException* CreatePresentationError(
const mojom::blink::PresentationError& error) {
ExceptionCode code = kUnknownError;
switch (error.error_type) {
case mojom::blink::PresentationErrorType::NO_AVAILABLE_SCREENS:
case mojom::blink::PresentationErrorType::NO_PRESENTATION_FOUND:
code = kNotFoundError;
break;
case mojom::blink::PresentationErrorType::PRESENTATION_REQUEST_CANCELLED:
code = kNotAllowedError;
break;
case mojom::blink::PresentationErrorType::PREVIOUS_START_IN_PROGRESS:
code = kOperationError;
break;
case mojom::blink::PresentationErrorType::UNKNOWN:
code = kUnknownError;
break;
}
return DOMException::Create(code, error.message);
}
} // namespace blink