1
0
mirror of https://github.com/oceanprotocol-archive/squid-js.git synced 2024-02-02 15:31:51 +01:00

improves some error messages

This commit is contained in:
Pedro Gutiérrez 2019-01-24 12:57:03 +01:00
parent 86b406ad2e
commit 68d551dc09
6 changed files with 15 additions and 10 deletions

View File

@ -69,8 +69,7 @@ async function exec() {
consumer, consumer,
) )
} catch (e) { } catch (e) {
Logger.warn("Error on initializeServiceAgreement:", e) throw new Error(`"Error on initializeServiceAgreement: ${e}`)
process.exit(1)
} }
} }

View File

@ -4,7 +4,7 @@ export function runner(fn: () => Promise<any>) {
fn() fn()
.then(() => process.exit(0)) .then(() => process.exit(0))
.catch((e) => { .catch((e) => {
Logger.warn(e) Logger.error(e)
process.exit(1) process.exit(1)
}) })
} }

View File

@ -3,6 +3,7 @@ import * as EthJsUtils from "ethereumjs-util"
import Keeper from "../keeper/Keeper" import Keeper from "../keeper/Keeper"
import Web3Provider from "../keeper/Web3Provider" import Web3Provider from "../keeper/Web3Provider"
import Balance from "../models/Balance" import Balance from "../models/Balance"
import Logger from "../utils/Logger"
import OceanBase from "./OceanBase" import OceanBase from "./OceanBase"
/** /**
@ -57,9 +58,15 @@ export default class Account extends OceanBase {
* @return {Promise<number>} * @return {Promise<number>}
*/ */
public async requestTokens(amount: number): Promise<number> { public async requestTokens(amount: number): Promise<number> {
try {
await (await Keeper.getInstance()) await (await Keeper.getInstance())
.market .market
.requestTokens(amount, this.id) .requestTokens(amount, this.id)
} catch (e) {
Logger.error(e)
throw new Error("Error requesting tokens")
}
return amount return amount
} }

View File

@ -249,7 +249,6 @@ export default class Ocean {
}) })
event.listenOnce(async (data) => { event.listenOnce(async (data) => {
const sa: ServiceAgreement = new ServiceAgreement(data.returnValues.serviceAgreementId) const sa: ServiceAgreement = new ServiceAgreement(data.returnValues.serviceAgreementId)
await sa.payAsset( await sa.payAsset(
d.getId(), d.getId(),
@ -263,7 +262,6 @@ export default class Ocean {
serviceAgreementId, serviceAgreementId,
serviceAgreementSignature, serviceAgreementSignature,
} }
} catch (err) { } catch (err) {
Logger.error("Signing ServiceAgreement failed!", err) Logger.error("Signing ServiceAgreement failed!", err)
} }

View File

@ -70,6 +70,7 @@ export default class ServiceAgreementTemplate extends OceanBase {
this.template.fulfillmentOperator, this.template.fulfillmentOperator,
templateOwnerAddress) templateOwnerAddress)
} catch (e) { } catch (e) {
Logger.error(e)
throw new Error(`Is not possible to setup the agreement template`) throw new Error(`Is not possible to setup the agreement template`)
} }

View File

@ -38,8 +38,8 @@ export default class WebServiceConnector {
private async fetch(url: string, opts: RequestInit): Promise<Response> { private async fetch(url: string, opts: RequestInit): Promise<Response> {
const result = await fetch(url, opts) const result = await fetch(url, opts)
if (!result.ok) { if (!result.ok) {
Logger.warn(`Error requesting [${opts.method}] ${url}`) Logger.error(`Error requesting [${opts.method}] ${url}`)
Logger.warn(`Response message: \n${await result.text()}`) Logger.error(`Response message: \n${await result.text()}`)
throw result throw result
} }
return result return result