Last active
March 1, 2018 11:37
-
-
Save rabeesh/23d62f301c6c8c976aaa6b540f755432 to your computer and use it in GitHub Desktop.
Async/await in normal way
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Domain { | |
constructor(config, dal) { | |
this.dal = dal; | |
this.config = config; | |
this.domainName = null; | |
this.sslRedirect = false; | |
this.paymentRequired = false; | |
} | |
async load() { | |
try { | |
const domain = that.dal.getDomain(); | |
this.domainName = domain.domain; | |
this.sslRedirect = domain.sslRedirect; | |
this.paymentRequired = domain.paymentRequired; | |
} catch(err) { | |
Failboat.tag(err, 'LoadDomain'); | |
if (err.tags.join(' ') !== '404 DomainNotCreated LoadDomain') { | |
throw err; | |
} | |
if (this.config.SUBSCRIPTION_API_ENABLED) { | |
try { | |
return await this.dal.createService() | |
} catch(err) { | |
Failboat.tag(err, 'CreateService'); | |
throw err; | |
} | |
} | |
try { | |
return await this.dal.createDomain(); | |
} catch(err) { | |
Failboat.tag(err, 'CreateDomain'); | |
throw err; | |
} | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment