briandelmsft / STAT-Function

Azure Function for the Microsoft Sentinel Triage AssistanT (STAT)
https://aka.ms/mstat
MIT License
9 stars 1 forks source link

Adding STATNotFound Exception #25

Closed briandelmsft closed 1 year ago

briandelmsft commented 1 year ago

We had a number of places where we were catching a STATError just to see if it was due to a 404 and re-raising it if it wasn't. The definition of a new STATNotFound exception which is thrown by the rest (get/post/put) functions makes this handling easier.

As STATNotFound is defined as a child of STATError, the old way will still work so if I missed updating one of the cases where we were checking for 404 it will still continue be caught by a STATError handler.

Old Method

            except STATError as e:
                if e.source_error['status_code'] == 404:
                    pass
                else:
                    raise STATError(e.error, e.source_error, e.status_code)

New Method

            except STATNotFound:
                pass