replaysMike / Binner

Open source parts inventory system for makers, electronics hobby, and professional engineers
https://binner.io
GNU General Public License v3.0
268 stars 41 forks source link

Improvements to DigiKey Search and Inventory Error Handling #68

Closed michaelajax closed 1 year ago

michaelajax commented 1 year ago

Hi, I have some improvements to the app for your consideration:

"Connectors" Part Type fails DigiKey loookup

This part type has no AlternateIds. This causes the call to enumValueMemberInfo.GetCustomAttributes to return a zero length array, which then throws an exception on the line below that tries to access element 0. The client gets nothing back and just spins indefinitely.

It looks like you have all the AlternateId stuff commented out anyway, but I still wrapped this all in an if statement to check array length before accessing it.

Saving Inventory without Part Type/Mounting Type fails without feedback

This seems to be more due to an issue mostly with DigiKey order import. When importing orders, it creates entries in the database with no Part Type or Mounting Type set. But your PartController class requires these and returns 400 if they aren't there.

So, if you import an order, then try to edit any other fields and click save without also setting these, nothing happens and there is no error in the client since there is no handling for a 400.

I made a small adjustment to inform the user what might be wrong. Here's some notes for your consideration:

DigiKey Search Ignoring Out of Stock

I have some parts that I was trying to manually add to my inventory, that I had bought from DigiKey. But, they wouldn't come up. It turns out there was a filter explicitly only searching for "InStock".

I removed this filter, which I think is harmless, since people may have and want to inventory parts that are not currently in stock - but there might have been a reason why it was there.

Thanks!

replaysMike commented 1 year ago

Looks good!