“But if the sun has risen on him, there will be the guilt of bloodshed for him.” Exodus 22:2-3 is about the ability of a person or family to protect their life and property. When comparing Exodus 22:2 with Exodus 22:3, it can be deduced that Exodus 22:2 is about a thief or someone coming into the house at night. In those days before lights, that could be a very dangerous situation, and the people in the house had to assume the intruder was dangerous, and that they needed to do whatever they could to defend themselves, which sometimes involved killing the intruder. In contrast, in Exodus 22:3 the sun was up and so it could be seen who the intruder was and if they were dangerous or not. Of course, if an intruder was dangerous and of evil intent then a person could lawfully defend himself, but if it could be seen that the intruder was no real danger but the homeowner killed him anyway, then the homeowner would be judged for his action.
“A thief.” The Hebrew is literally, “he,” but that might cause confusion in the flow of this context. It refers to the thief.