WebTransportError.h (1426B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef DOM_WEBTRANSPORT_API_WEBTRANSPORTERROR__H_ 8 #define DOM_WEBTRANSPORT_API_WEBTRANSPORTERROR__H_ 9 10 #include "mozilla/dom/DOMException.h" 11 #include "mozilla/dom/WebTransportErrorBinding.h" 12 13 namespace mozilla::dom { 14 class WebTransportError final : public DOMException { 15 public: 16 explicit WebTransportError( 17 const nsACString& aMessage, 18 WebTransportErrorSource aSource = WebTransportErrorSource::Stream, 19 Nullable<uint8_t> aCode = Nullable<uint8_t>()) 20 : DOMException(NS_OK, aMessage, "WebTransportError"_ns, 0), 21 mStreamErrorCode(aCode), 22 mSource(aSource) {} 23 24 JSObject* WrapObject(JSContext* aCx, 25 JS::Handle<JSObject*> aGivenProto) override; 26 27 static already_AddRefed<WebTransportError> Constructor( 28 const GlobalObject& aGlobal, const WebTransportErrorInit& aInit); 29 30 WebTransportErrorSource Source() { return mSource; } 31 Nullable<uint8_t> GetStreamErrorCode() const { return mStreamErrorCode; } 32 33 private: 34 Nullable<uint8_t> mStreamErrorCode; 35 const WebTransportErrorSource mSource; 36 }; 37 38 } // namespace mozilla::dom 39 40 #endif