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

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -