PLATFORM-392 Throw error correctly