Which preposition in front of "line" — "on", "in", "at"?
You may be unaware of the differences commonly implied:
error in line#: you made an error while formulating or typing the line. (parsing/interpretring issue).
error on line #: on reaching the line, you encounter an error probably being inconsistant with preceding logic. (logical/compiler error).
error at line#: likely the compilation or execution is interrupted/ aborted and currently, the pointer is at line#.
In your example, in for the first prep. and at for the second would be appropriate.
I think the first instance should be 'in', since the instance is being declared in the line of code, and that the second one should be 'at', since the error occurs while parsing the last line. The completed sentence IMHO should be
In the first line you create an instance of XXX and XXX leads to the runtime error at the last line.