|
| 1 | + |
| 2 | +/** |
| 3 | + * Copyright (C) 2016, Canonical Ltd. |
| 4 | + * All rights reserved. |
| 5 | + * |
| 6 | + * This source code is licensed under the BSD-style license found in the |
| 7 | + * LICENSE file in the root directory of this source tree. An additional grant |
| 8 | + * of patent rights can be found in the PATENTS file in the same directory. |
| 9 | + * |
| 10 | + * Author: Justin McPherson <justin.mcpherson@canonical.com> |
| 11 | + * |
| 12 | + */ |
| 13 | + |
| 14 | +#include "reactexceptionsmanager.h" |
| 15 | + |
| 16 | +#include "reactbridge.h" |
| 17 | +#include "reactredboxitem.h" |
| 18 | + |
| 19 | + |
| 20 | +class ReactExceptionsManagerPrivate { |
| 21 | +public: |
| 22 | + ReactBridge* bridge = nullptr; |
| 23 | +}; |
| 24 | + |
| 25 | + |
| 26 | +void ReactExceptionsManager::reportSoftException( |
| 27 | + const QString& message, |
| 28 | + const QList<QVariantMap>& stack, |
| 29 | + int exceptionId |
| 30 | +) { |
| 31 | + d_func()->bridge->redbox()->showErrorMessage(message, stack); |
| 32 | +} |
| 33 | + |
| 34 | +void ReactExceptionsManager::reportFatalException( |
| 35 | + const QString& message, |
| 36 | + const QList<QVariantMap>& stack, |
| 37 | + int exceptionId |
| 38 | +) { |
| 39 | + d_func()->bridge->redbox()->showErrorMessage(message, stack); |
| 40 | + |
| 41 | + // XXX: leaving out reload attempts for now |
| 42 | +} |
| 43 | + |
| 44 | +void ReactExceptionsManager::updateExceptionMessage( |
| 45 | + const QString& message, |
| 46 | + const QList<QVariantMap>& stack, |
| 47 | + int exceptionId |
| 48 | +) { |
| 49 | + d_func()->bridge->redbox()->updateErrorMessage(message, stack); |
| 50 | +} |
| 51 | + |
| 52 | +void ReactExceptionsManager::reportUnhandledException( |
| 53 | + const QString& message, |
| 54 | + const QList<QVariantMap>& stack |
| 55 | +) { |
| 56 | + reportFatalException(message, stack, 1); |
| 57 | +} |
| 58 | + |
| 59 | + |
| 60 | +ReactExceptionsManager::ReactExceptionsManager(QObject* parent) |
| 61 | + : QObject(parent) |
| 62 | + , d_ptr(new ReactExceptionsManagerPrivate) |
| 63 | +{ |
| 64 | +} |
| 65 | + |
| 66 | +ReactExceptionsManager::~ReactExceptionsManager() |
| 67 | +{ |
| 68 | +} |
| 69 | + |
| 70 | +void ReactExceptionsManager::setBridge(ReactBridge* bridge) |
| 71 | +{ |
| 72 | + Q_D(ReactExceptionsManager); |
| 73 | + d->bridge = bridge; |
| 74 | +} |
| 75 | + |
| 76 | +ReactViewManager* ReactExceptionsManager::viewManager() |
| 77 | +{ |
| 78 | + return nullptr; |
| 79 | +} |
| 80 | + |
| 81 | +QString ReactExceptionsManager::moduleName() |
| 82 | +{ |
| 83 | + return "RCTExceptionsManager"; |
| 84 | +} |
| 85 | + |
| 86 | +QList<ReactModuleMethod*> ReactExceptionsManager::methodsToExport() |
| 87 | +{ |
| 88 | + return QList<ReactModuleMethod*>{}; |
| 89 | +} |
| 90 | + |
| 91 | +QVariantMap ReactExceptionsManager::constantsToExport() |
| 92 | +{ |
| 93 | + return QVariantMap{}; |
| 94 | +} |
| 95 | + |
0 commit comments