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 file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_workers_WorkerError_h
8 #define mozilla_dom_workers_WorkerError_h
10 #include "mozilla/dom/SerializedStackHolder.h"
11 #include "mozilla/dom/WorkerCommon.h"
16 class DOMEventTargetHelper
;
21 class WorkerErrorBase
{
26 uint32_t mColumnNumber
;
27 uint32_t mErrorNumber
;
29 WorkerErrorBase() : mLineNumber(0), mColumnNumber(0), mErrorNumber(0) {}
31 void AssignErrorBase(JSErrorBase
* aReport
);
34 class WorkerErrorNote
: public WorkerErrorBase
{
36 void AssignErrorNote(JSErrorNotes::Note
* aNote
);
41 class WorkerErrorReport
: public WorkerErrorBase
, public SerializedStackHolder
{
47 nsTArray
<WorkerErrorNote
> mNotes
;
51 void AssignErrorReport(JSErrorReport
* aReport
);
53 // aWorkerPrivate is the worker thread we're on (or the main thread, if null)
54 // aTarget is the worker object that we are going to fire an error at
56 static void ReportError(
57 JSContext
* aCx
, WorkerPrivate
* aWorkerPrivate
, bool aFireAtScope
,
58 DOMEventTargetHelper
* aTarget
, UniquePtr
<WorkerErrorReport
> aReport
,
59 uint64_t aInnerWindowId
,
60 JS::Handle
<JS::Value
> aException
= JS::NullHandleValue
);
62 static void LogErrorToConsole(JSContext
* aCx
, WorkerErrorReport
& aReport
,
63 uint64_t aInnerWindowId
);
65 static void LogErrorToConsole(const mozilla::dom::ErrorData
& aReport
,
66 uint64_t aInnerWindowId
,
67 JS::HandleObject aStack
= nullptr,
68 JS::HandleObject aStackGlobal
= nullptr);
70 static void CreateAndDispatchGenericErrorRunnableToParent(
71 WorkerPrivate
* aWorkerPrivate
);
75 } // namespace mozilla
77 #endif // mozilla_dom_workers_WorkerError_h