FileIOErrorHandler.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <Utils/FileIOErrorHandler.h>
  9. namespace AtomSampleViewer
  10. {
  11. void FileIOErrorHandler::OnError([[maybe_unused]] const AZ::IO::SystemFile* file, [[maybe_unused]] const char* fileName, int errorCode)
  12. {
  13. m_ioErrorCode = errorCode;
  14. }
  15. void FileIOErrorHandler::BusConnect()
  16. {
  17. Base::BusConnect();
  18. m_ioErrorCode = ErrorCodeNotSet;
  19. }
  20. void FileIOErrorHandler::ReportLatestIOError(AZStd::string message)
  21. {
  22. AZ_Assert(BusIsConnected(), "FileIOErrorHandler must be connected while calling ReportLatestIOError");
  23. if (m_ioErrorCode != ErrorCodeNotSet)
  24. {
  25. message += AZStd::string::format(" IO error code %d.", m_ioErrorCode);
  26. }
  27. AZ_Error("FileIOErrorHandler", false, "%s", message.c_str());
  28. }
  29. void FileIOErrorHandler::BusDisconnect()
  30. {
  31. Base::BusDisconnect();
  32. m_ioErrorCode = ErrorCodeNotSet;
  33. }
  34. } // namespace AtomSampleViewer