{"record":{"id":"0d730c892304734d","repo":"stride3d/stride","slug":"notsupportedexception-value","errorCode":null,"errorMessage":"NotSupportedException: value","messagePattern":"NotSupportedException: value","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Physics/Elements/RigidbodyComponent.cs","lineNumber":295,"sourceCode":"\n                switch (value)\n                {\n                    case RigidBodyTypes.Dynamic:\n                        InternalRigidBody.CollisionFlags &= ~(BulletSharp.CollisionFlags.StaticObject | BulletSharp.CollisionFlags.KinematicObject);\n                        break;\n\n                    case RigidBodyTypes.Static:\n                        InternalRigidBody.CollisionFlags &= ~BulletSharp.CollisionFlags.KinematicObject;\n                        InternalRigidBody.CollisionFlags |= BulletSharp.CollisionFlags.StaticObject;\n                        break;\n\n                    case RigidBodyTypes.Kinematic:\n                        InternalRigidBody.CollisionFlags &= ~BulletSharp.CollisionFlags.StaticObject;\n                        InternalRigidBody.CollisionFlags |= BulletSharp.CollisionFlags.KinematicObject;\n                        break;\n\n                    default:\n                        throw new NotSupportedException(nameof(value));\n                }\n                if (!OverrideGravity)\n                {\n                    if (value == RigidBodyTypes.Dynamic)\n                    {\n                        InternalRigidBody.Gravity = Simulation.Gravity;\n                    }\n                    else\n                    {\n                        InternalRigidBody.Gravity = Vector3.Zero;\n                    }\n                }\n                InternalRigidBody.InterpolationAngularVelocity = Vector3.Zero;\n                InternalRigidBody.LinearVelocity = Vector3.Zero;\n                InternalRigidBody.InterpolationAngularVelocity = Vector3.Zero;\n                InternalRigidBody.AngularVelocity = Vector3.Zero;\n            }\n        }","sourceCodeStart":277,"sourceCodeEnd":313,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Physics/Elements/RigidbodyComponent.cs#L277-L313","documentation":"The RigidBodyTypes property setter switches Bullet collision flags per type (Dynamic/Static/Kinematic). Any other value hits the default branch and throws NotSupportedException with the member name 'value'.","triggerScenarios":"Assigning PhysicsComponent.RigidBodyTypes with an enum value outside the supported set, e.g. an invalid cast of an int to RigidBodyTypes.","commonSituations":"Loading enum values from config/serialization where the int no longer matches a defined enum member; adding a new enum member without updating this switch; cross-version data where the enum definition changed.","solutions":["Only assign valid RigidBodyTypes values: Dynamic, Static, or Kinematic","Validate the enum value with Enum.IsDefined before assigning","Fix any int->enum casts producing out-of-range values"],"exampleFix":"// before\nrigidbody.RigidBodyTypes = (RigidBodyTypes)42; // throws NotSupportedException\n// after\nvar t = (RigidBodyTypes)42;\nif (Enum.IsDefined(typeof(RigidBodyTypes), t))\n    rigidbody.RigidBodyTypes = t;","handlingStrategy":"validation","validationCode":"if (!Enum.IsDefined(typeof(RigidBodyTypes), value))\n    throw new InvalidEnumArgumentException(nameof(value), (int)value, typeof(RigidBodyTypes));","typeGuard":null,"tryCatchPattern":"try { rigidbody.RigidBodyTypes = t; }\ncatch (NotSupportedException) { /* invalid enum value from data */ }","preventionTips":["Use Enum.IsDefined before casting ints to RigidBodyTypes","Keep enum definitions in sync across versions","Avoid round-tripping enums as raw ints in configs"],"tags":["physics","enum","csharp"],"backgroundTag":"invalid-enum-value","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}