diff options
Diffstat (limited to 'devtools/client/debugger/src/reducers/exceptions.js')
-rw-r--r-- | devtools/client/debugger/src/reducers/exceptions.js | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/devtools/client/debugger/src/reducers/exceptions.js b/devtools/client/debugger/src/reducers/exceptions.js new file mode 100644 index 0000000000..f4d98115ea --- /dev/null +++ b/devtools/client/debugger/src/reducers/exceptions.js @@ -0,0 +1,47 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */ + +/** + * Exceptions reducer + * @module reducers/exceptionss + */ + +export function initialExceptionsState() { + return { + exceptions: {}, + }; +} + +function update(state = initialExceptionsState(), action) { + switch (action.type) { + case "ADD_EXCEPTION": + return updateExceptions(state, action); + } + return state; +} + +function updateExceptions(state, action) { + const { exception } = action; + const sourceActorId = exception.sourceActorId; + + if (state.exceptions[sourceActorId]) { + const sourceExceptions = state.exceptions[sourceActorId]; + return { + ...state, + exceptions: { + ...state.exceptions, + [sourceActorId]: [...sourceExceptions, exception], + }, + }; + } + return { + ...state, + exceptions: { + ...state.exceptions, + [sourceActorId]: [exception], + }, + }; +} + +export default update; |