exceptions.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License in the LICENSE file at the
  6. # root of this repository, or online at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. from typing import Any
  16. from dbt_common.exceptions import CompilationError
  17. class RefreshIntervalConfigNotDictError(CompilationError):
  18. def __init__(self, raw_refresh_interval: Any):
  19. self.raw_refresh_interval = raw_refresh_interval
  20. super().__init__(msg=self.get_message())
  21. def get_message(self) -> str:
  22. msg = (
  23. f"Invalid refresh_interval config:\n"
  24. f" Got: {self.raw_refresh_interval}\n"
  25. f' Expected a dictionary with at minimum a "at", "at_creation", or "every" key'
  26. )
  27. return msg
  28. class RefreshIntervalConfigError(CompilationError):
  29. def __init__(self, exc: TypeError):
  30. self.exc = exc
  31. super().__init__(msg=self.get_message())
  32. def get_message(self) -> str:
  33. validator_msg = self.validator_error_message(self.exc)
  34. msg = f"Could not parse refresh interval config: {validator_msg}"
  35. return msg