Skip to content

Commit

Permalink
chore: add _isComponentDidCatchEnabled
Browse files Browse the repository at this point in the history
  • Loading branch information
bchelkowski committed Feb 16, 2024
1 parent 3b31ef8 commit 135edbf
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/components/renderer/Kopytko.brs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@ sub init()
m.state = {}
m.elementToFocus = Invalid

m._enabledErrorCatching = false
#if enableKopytkoComponentDidCatch
m._enabledErrorCatching = true
#end if
m._enabledErrorCatching = m._enabledErrorCatching AND Type(componentDidCatch) <> "<uninitialized>"

m._enabledErrorCatching = _isComponentDidCatchEnabled()
m._isInitialized = false
m._previousProps = {}
m._previousState = {}
Expand Down Expand Up @@ -143,6 +138,16 @@ function _cloneObject(obj as Object) as Object
return newObj
end function

function _isComponentDidCatchEnabled() as Boolean
enabledErrorCatching = false

#if enableKopytkoComponentDidCatch
enabledErrorCatching = true
#end if

return enabledErrorCatching AND Type(componentDidCatch) <> "<uninitialized>"
end function

sub _methodCall(func as Function, methodName as String, args = [] as Object, context = Invalid as Object)
if (m._enabledErrorCatching)
try
Expand Down

0 comments on commit 135edbf

Please sign in to comment.