cli-microsoft365 icon indicating copy to clipboard operation
cli-microsoft365 copied to clipboard

Include stack trace in errors, Closes #5660

Open nicodecleyre opened this issue 2 years ago • 12 comments

While working on this, i could not get the trace errors higher then the handleRejectedODataPromise & the handleRejectedODataPromise functions. For the tests i had to stub the cli options 🤔 , don't know if there is another, better way

Closes #5660

nicodecleyre avatar Jan 05 '24 21:01 nicodecleyre

Thank you @nicodecleyre, we'll have a look at it ASAP!

milanholemans avatar Jan 05 '24 21:01 milanholemans

How can we test how this works @nicodecleyre?

waldekmastykarz avatar Jan 20 '24 14:01 waldekmastykarz

How can we test how this works @nicodecleyre?

I thought of: On the one hand by stubbing the debug option, on the other hand by mocking a stack error. Is there another, better way that you have in mind?

nicodecleyre avatar Jan 31 '24 11:01 nicodecleyre

How can we test how this works @nicodecleyre?

I thought of: On the one hand by stubbing the debug option, on the other hand by mocking a stack error. Is there another, better way that you have in mind?

I meant more: how can we see it in action. Stubs and mocks are based on assumptions, but how can we confirm that these are correct? How can we use CLI to see how it's handled in practice?

waldekmastykarz avatar Feb 01 '24 09:02 waldekmastykarz

How can we test how this works @nicodecleyre?

I thought of: On the one hand by stubbing the debug option, on the other hand by mocking a stack error. Is there another, better way that you have in mind?

I meant more: how can we see it in action. Stubs and mocks are based on assumptions, but how can we confirm that these are correct? How can we use CLI to see how it's handled in practice?

Got it, during testing I deliberately entered an incorrect command. For this I have used spo lisitem set with a field that does not exist. In this case 'InvalidField' image

Which result in an error witht a stack trace: image

nicodecleyre avatar Feb 04 '24 10:02 nicodecleyre

Thanks! I'll try that!

waldekmastykarz avatar Feb 04 '24 11:02 waldekmastykarz

Hey @nicodecleyre, are you still working on this?

waldekmastykarz avatar Mar 23 '24 09:03 waldekmastykarz

Hi @waldekmastykarz, I certainly am. I've done some research regarding another solution in every spare time I have, just haven't found it yet

nicodecleyre avatar Mar 23 '24 10:03 nicodecleyre

Hi @waldekmastykarz, I investigated this further but the stacktrace has no reference to the cli code files at any time, not even in the command.action. I have also looked for npm modules that could help with this, but they always read from the stack trace, which has no reference to our code files to begin with.

I was wondering if we can formulate a solid solution to this question?

nicodecleyre avatar Apr 07 '24 09:04 nicodecleyre

Thanks for looking into it @nicodecleyre. I wonder if it would help, if we caught exceptions in the CLI code and threw a new one, so that we can capture information from the CLI code which we control rather than the dependencies with which we can do nothing.

waldekmastykarz avatar Apr 08 '24 17:04 waldekmastykarz

Thanks for looking into it @nicodecleyre. I wonder if it would help, if we caught exceptions in the CLI code and threw a new one, so that we can capture information from the CLI code which we control rather than the dependencies with which we can do nothing.

A-Mazing, this could go through with it, throwing an error from handleRejectedODataJsonPromise or handleRejectedODataPromise. Thanks a thousand times Waldek!!: image

nicodecleyre avatar Apr 13 '24 21:04 nicodecleyre

This looks way more meaningful! I'll have a closer look at it asap. Great find! 🚀

waldekmastykarz avatar Apr 14 '24 17:04 waldekmastykarz