NCKitError
Typed errors from all NCKit APIs.
Definitionโ
public enum NCKitError: Error, Sendable {
case missingModel(String)
case libraryInit
case badFrameLength(Int)
case cannotOpenInput
case cannotCreateOutput
case unsupportedFormat
case resampleFailed
}
Handle errorsโ
do {
let modelURL = try NCKitModelLocator.modelTarGzURL()
let processor = try NCKitProcessor(modelURL: modelURL)
try NCKitFileProcessor.processFile(
inputURL: inputURL,
outputURL: outputURL,
processor: processor
)
} catch NCKitError.missingModel(let name) {
// NCKit_model.tar.gz not embedded
} catch NCKitError.libraryInit {
// libdf failed to load model
} catch NCKitError.cannotOpenInput {
// input file not readable
} catch NCKitError.cannotCreateOutput {
// output file not writable
} catch NCKitError.unsupportedFormat {
// no decodable audio track
} catch NCKitError.resampleFailed {
// AVAudioConverter failed
} catch NCKitError.badFrameLength(let n) {
// wrong hop size for processFrame
} catch {
// other system errors
}
Casesโ
| Case | Source |
|---|---|
missingModel / MissingModel | NCKitModelLocator |
libraryInit / LibraryInit | NCKitProcessor init |
badFrameLength / BadFrameLength | NCKitProcessor.processFrame wrong buffer size (480 samples) |
cannotOpenInput / CannotOpenInput | NCKitFileProcessor.processFile |
cannotCreateOutput / CannotCreateOutput | NCKitFileProcessor.processFile |
unsupportedFormat / UnsupportedFormat | NCKitFileProcessor.processFile |
resampleFailed / ResampleFailed | NCKitFileProcessor.processFile |