Refactor exceptions

* Suffix names for custom exceptions with "Error"
* Introduce exceptions for when the coressponding encoder isn't found
This commit is contained in:
Ritiek Malhotra
2020-03-17 03:09:56 +05:30
parent 083c430489
commit 29005f24ed
16 changed files with 276 additions and 28 deletions

View File

@@ -1,8 +1,11 @@
import shutil
import os
from abc import ABC
from abc import abstractmethod
from spotdl.encode.exceptions import EncoderNotFoundError
"""
NOTE ON ENCODERS
================
@@ -25,6 +28,12 @@ from abc import abstractmethod
class EncoderBase(ABC):
@abstractmethod
def __init__(self, encoder_path, loglevel, additional_arguments):
if shutil.which(encoder_path) is None:
raise EncoderNotFoundError(
"{} executable does not exist or was not found in PATH.".format(
encoder_path
)
)
self.encoder_path = encoder_path
self._loglevel = loglevel
self._additional_arguments = additional_arguments