PipelineError.cpp (1226B)
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6 #include "PipelineError.h" 7 8 #include "mozilla/RefPtr.h" 9 #include "nsIGlobalObject.h" 10 11 namespace mozilla::webgpu { 12 13 GPU_IMPL_JS_WRAP(PipelineError) 14 15 PipelineError::PipelineError(const nsACString& aMessage, 16 dom::GPUPipelineErrorReason aReason) 17 : dom::DOMException(nsresult::NS_OK, aMessage, "GPUPipelineError"_ns, 0), 18 mReason(aReason) {} 19 20 /*static*/ already_AddRefed<PipelineError> PipelineError::Constructor( 21 const dom::GlobalObject& aGlobal, const nsAString& aMessage, 22 const dom::GPUPipelineErrorInit& aOptions) { 23 nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aGlobal.GetAsSupports()); 24 MOZ_RELEASE_ASSERT(global); 25 26 auto reason = aOptions.mReason; 27 NS_ConvertUTF16toUTF8 msg(aMessage); 28 auto error = MakeRefPtr<PipelineError>(msg, reason); 29 return error.forget(); 30 } 31 32 dom::GPUPipelineErrorReason PipelineError::Reason() const { return mReason; } 33 34 } // namespace mozilla::webgpu