# How to debug "type Nothing has no field color"

**URL:** <https://discourse.julialang.org/t/how-to-debug-type-nothing-has-no-field-color/103038>\
**Category:** Visualization\
**Tags:** package, glmakie\
**Created:** [August 21, 2023, 4:14pm UTC](https://discourse.julialang.org/t/how-to-debug-type-nothing-has-no-field-color/103038 "2023-08-21T16:14:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [August 21, 2023, 4:14pm UTC](https://discourse.julialang.org/t/how-to-debug-type-nothing-has-no-field-color/103038/1 "2023-08-21T16:14:08Z")

</div>

I hit the following bug: [Switch on the tutorial project · Issue #8 · bradcarman/ModelingToolkitDesigner.jl · GitHub](https://github.com/bradcarman/ModelingToolkitDesigner.jl/issues/8)

But the author of the package cannot reproduce it. How can we find the reason for this bug?

Can anybody else reproduce it?

---

<div class="post-metadata">

**Author:** ![fatteneder](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fatteneder/32/33991_2.png) [@fatteneder](https://discourse.julialang.org/u/fatteneder)\
**Post date:** [August 21, 2023, 4:31pm UTC](https://discourse.julialang.org/t/how-to-debug-type-nothing-has-no-field-color/103038/2 "2023-08-21T16:31:08Z")

</div>

The stack trace of albheim in that issue say that the problem is on line 578 in `src/ModelingToolkitDesigner.jl` on version `v1.0.0`: [https://github.com/bradcarman/ModelingToolkitDesigner.jl/blob/f56140e8b4c46583f71ab8d694bff64376cddde5/src/ModelingToolkitDesigner.jl#L569-L579](https://github.com/bradcarman/ModelingToolkitDesigner.jl/blob/f56140e8b4c46583f71ab8d694bff64376cddde5/src/ModelingToolkitDesigner.jl#L569-L579)

Looks like there is a `isnothing` check missing:

```julia
if !isnothing(selected_component)
    selected_component.color[] = :pink
else
    all_connectors =
        vcat([s.connectors for s in design.components]...)
    selected_connector = filtersingle(
        c -> is_tuple_approx(c.xy[], (x, y); atol = 1e-3),
        all_connectors,
    )
    selected_connector.color[] = :pink # line nr. 578
end

```

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [August 21, 2023, 4:43pm UTC](https://discourse.julialang.org/t/how-to-debug-type-nothing-has-no-field-color/103038/3 "2023-08-21T16:43:15Z")

</div>

Thanks a lot! 😀
