-
Notifications
You must be signed in to change notification settings - Fork 2
Namsonx/task/stabi branch #283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
JPP_1500 extended (partially commented out) JPP_1501 added (partially commented out)
…HolQue/task/selftest_maintenance
…stability Loading jsonp content improvement
…_maintenance Self test maintenance
In case of JSON syntax errors the log file contains an extract of the JSON content nearby the position, where the error occurred. Realizes: #279
…_maintenance Extended debugging support
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Son,
the performance issues are solved. Your code looks good. But I cannot find the new output
failedJsonDoc (lines starting with "Nearby: "). I am confused.
Have you tested the output?
if failedJsonDoc is None:
print(f"================================= is None")
jsonException = f"{error}\nIn file: '{jFile}'"
else:
print(f"================================= is not None")
jsonException = f"{error}\nNearby: '{failedJsonDoc}'\nIn file: '{jFile}'"
is None always
if failedJsonDoc is None:
print(f"================================= is None (2)")
jsonException = f"${error}\nIn file: '{jFile}'"
else:
print(f"================================= is None (2)")
jsonException = f"${error}\nNearby: '{failedJsonDoc}'\nIn file: '{jFile}'"
Still ${error} ;-)
Is always not a JSON exception object. Means: .doc is not an element of jsonDecodeError. I have no idea why.
def __getFailedJsonDoc(jsonDecodeError=None, areaBeforePosition=50, areaAfterPosition=20, oneLine=True):
failedJsonDoc = None
if jsonDecodeError is None:
return failedJsonDoc
try:
jsonDoc = jsonDecodeError.doc
except:
# 'jsonDecodeError' seems not to be a JSON exception object ('doc' not available)
print(f"================================= NOT a JSON exception object")
return failedJsonDoc
No such problems when accessing .doc immediately:
except Exception as error:
self.__reset()
intermediateDocOutput = error.doc
print(f"================================= intermediateDocOutput (1): {intermediateDocOutput}")
failedJsonDoc = self.__getFailedJsonDoc(error)
jsonException = "not defined"
if failedJsonDoc is None:
print(f"================================= is None")
jsonException = f"{error}\nIn file: '{jFile}'"
else:
print(f"================================= is not None")
jsonException = f"{error}\nNearby: '{failedJsonDoc}'\nIn file: '{jFile}'"
raise Exception(jsonException)
Assumption: Something went wrong when passing the error to:
failedJsonDoc = self.__getFailedJsonDoc(error)
Still no idea why.
Trying to summarize:
Within an except block we have an exception object available. If we pass this exception object to a method of the same class, we get lost of this object. This in new to me.
We need access to two informations:
jsonDecodeError.doc
jsonDecodeError.pos
Therefore, instead of:
def __getFailedJsonDoc(jsonDecodeError=None, areaBeforePosition=50, areaAfterPosition=20, oneLine=True):
an alternative implementation could be:
jsonDecodeErrorPos = jsonDecodeError.pos
jsonDecodeErrorDoc = jsonDecodeError.doc
def __getFailedJsonDoc(jsonDecodeErrorPos=None, jsonDecodeErrorDoc=None, areaBeforePosition=50, areaAfterPosition=20, oneLine=True):
I print what I put inside __getFailedJsonDoc:
except Exception as error:
self.__reset()
print(f"================================= (1) error.pos: {error.pos}")
print(f"================================= (1) error.doc: {error.doc}")
failedJsonDoc = self.__getFailedJsonDoc(error.pos, error.doc)
And I print what I get inside the method:
def __getFailedJsonDoc(jsonDecodeErrorPos=None, jsonDecodeErrorDoc=None, areaBeforePosition=50, areaAfterPosition=20, oneLine=True):
failedJsonDoc = None
if ( (jsonDecodeErrorPos is None) or (jsonDecodeErrorDoc is None) ):
return failedJsonDoc
print(f"================================= (__getFailedJsonDoc) jsonDecodeErrorPos: {jsonDecodeErrorPos}")
print(f"================================= (__getFailedJsonDoc) jsonDecodeErrorDoc: {jsonDecodeErrorDoc}")
Result:
================================= (1) error.pos: 15
================================= (1) error.doc: {
"param1" : 1
"param2" : 2
}
================================= (__getFailedJsonDoc) jsonDecodeErrorPos: <JsonPreprocessor.CJsonPreprocessor.CJsonPreprocessor object at 0x000001BEA02394C0>
================================= (__getFailedJsonDoc) jsonDecodeErrorDoc: 15
I am lost now :-(
Hello Holger, I tried to move the function getFailedJsonDoc out of the CJsonPreprocessor class, then the "Nearby: ..." log appears. Thank you, |
|
Hi Son, yes, I agree. |
|
Hi Son, the self is missing:
Should be def __getFailedJsonDoc(self, jsonDecodeError=None, areaBeforePosition=50, areaAfterPosition=20, oneLine=True): o.m.g. |
|
Success! The " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Son,
looks good to me!
Thank you,
Thomas
No description provided.