chromium/third_party/blink/renderer/platform/bindings/exception_code.h

// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_BINDINGS_EXCEPTION_CODE_H_
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_BINDINGS_EXCEPTION_CODE_H_

namespace blink {

// DOMException uses |unsigned short| for exception codes.
// https://webidl.spec.whatwg.org/#idl-DOMException
// In our DOM implementation we use |int| instead, and use different numerical
// ranges for different types of exceptions (not limited to DOMException), so
// that an exception of any type can be expressed with a single integer.
//
// Zero value in ExceptionCode means no exception being thrown.
ExceptionCode;

// DOMException's error code
// https://webidl.spec.whatwg.org/#idl-DOMException-error-names
enum class DOMExceptionCode : ExceptionCode {};

inline bool IsDOMExceptionCode(ExceptionCode exception_code) {}

// Exception codes that correspond to ECMAScript Error objects and
// other errors derived from ECMAScript's NativeError class like
// WebAssembly errors.
// https://tc39.github.io/ecma262/#sec-error-objects
enum class ESErrorType : ExceptionCode {};

// Exception codes used only inside ExceptionState implementation.
enum class InternalExceptionType : ExceptionCode {};

// Upcast from DOMExceptionCode to ExceptionCode as ExceptionCode is considered
// as an union of DOMExceptionCode and ESErrorType.
// Downcast should be performed with explicit static_cast with a range check.
inline ExceptionCode ToExceptionCode(DOMExceptionCode exception_code) {}

// Upcast from ESErrorType to ExceptionCode as ExceptionCode is considered
// as an union of DOMExceptionCode and ESErrorType.
// Downcast should be performed with explicit static_cast with a range check.
inline ExceptionCode ToExceptionCode(ESErrorType exception_code) {}

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_RENDERER_PLATFORM_BINDINGS_EXCEPTION_CODE_H_