Jul 4, 2019, 4:10:29 AM7/4/19
Not enough detail in your question to give an answer. No code and no platform/environment/version/programming-language details etc.
Do some debugging. If the problem is reproducible that will be easier. If the -501 does not repeat on demand, use code inspection , check for uncaught or ignored exceptions, check database diagnostics, check all code paths .