JuliaData / StructTypes.jl

Abstract definitions and convenience methods for describing, processing, and constructing Julia objects
https://juliadata.github.io/StructTypes.jl/stable/
MIT License
79 stars 22 forks source link

Define `Struct()` as the struct type for `<:Exception`? #71

Closed ericphanson closed 2 years ago

ericphanson commented 2 years ago

i.e.

StructTypes.StructType(::Type{<:Exception}) = StructTypes.Struct()

I think that's usually the case? (I'm trying to log exceptions as JSON). (This could be superceded by #61, but if we don't go for that, it might still make sense for exceptions).

ericwburden commented 2 years ago

I was able to accomplish this with

StructTypes.StructType(::Type{E}) where {E <: Exception} = StructTypes.Struct()
quinnj commented 2 years ago

Implemented in https://github.com/JuliaData/StructTypes.jl/pull/70