swift - How to nest low level errors and higher level errors? -
i have custom error type, low level http problems:
enum apiclienterror: errortype { case networkerror ... } in higher level layer have error type:
enum signinerror: errortype { case invaliduser ... } the problem have apiclienterror instances need bubble higher level layer , in function need return maybe apiclienterror, maybe signinerror.
how can declare function that? tried
typealias loginresult = result<successtype, errortype> but not work ('using errortype' concrete type conforming protocol 'errortype' not supported').
how can nest error types different layers in swift?
i scratching head this. way can think of doing this:
enum apiclienterror: errortype { case networkerror ... } enum signinerror: errortype { case invaliduser //note, name of case can't same type of error due compiler errors case apierror(apiclienterror) } this way errors bubble up. annoying thing unwrapping multiple levels of error nesting code handles errors.
Comments
Post a Comment