How to use getExceptionMessage method in Puppeteer

Best JavaScript code snippet using puppeteer

Run Puppeteer automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

NegociacaoController.js

Source: NegociacaoController.js Github

copy
1import { Negociacoes, NegociacaoService, Negociacao } from '../domain/index.js';
2import { NegociacoesView, MensagemView, Mensagem, DateConverter } from '../ui/index.js';
3import { getNegociacaoDao, Bind, getExceptionMessage, debounce, controller, bindEvent } from '../util/index.js';
4
5@controller('#data', '#quantidade', '#valor')
6export class NegociacaoController {
7
8    constructor(_inputData, _inputQuantidade, _inputValor) {
9
10        Object.assign(this, { _inputData, _inputQuantidade, _inputValor })
11        
12        this._negociacoes = new Bind(
13            new Negociacoes(),
14            new NegociacoesView('#negociacoes'),
15            'adiciona', 'esvazia'
16        );
17
18        this._mensagem = new Bind(
19            new Mensagem(),
20            new MensagemView('#mensagemView'),
21            'texto'
22        );
23
24        this._service = new NegociacaoService();
25
26        this._init();
27    }
28
29    async _init() {
30
31        try {
32            const dao = await getNegociacaoDao();
33            const negociacoes = await dao.listaTodos();
34            negociacoes.forEach(negociacao => this._negociacoes.adiciona(negociacao));
35        } catch (err) {
36            this._mensagem.texto = getExceptionMessage(err);
37        }
38    }
39
40    @bindEvent('submit', '.form')
41    @debounce()
42    async adiciona(event) {
43
44        try {
45            const negociacao = this._criaNegociacao();
46            const dao = await getNegociacaoDao();
47            await dao.adiciona(negociacao);
48            this._negociacoes.adiciona(negociacao);
49            this._mensagem.texto = 'Negociação adicionada com sucesso';
50            this._limpaFormulario();
51        } catch (err) {
52            this._mensagem.texto = getExceptionMessage(err);
53        }
54    }
55
56    _limpaFormulario() {
57
58        this._inputData.value = '';
59        this._inputQuantidade.value = 1;
60        this._inputValor.value = 0.0
61        this._inputData.focus();
62    }
63
64    _criaNegociacao() {
65
66        return new Negociacao(
67            DateConverter.paraData(this._inputData.value),
68            parseInt(this._inputQuantidade.value),
69            parseFloat(this._inputValor.value)
70        );
71    }
72
73    @bindEvent('click', '#botao-importa')
74    @debounce()
75    async importaNegociacoes() {
76
77        try {
78            const negociacoes = await this._service.obtemNegociacoesDoPeriodo();
79            console.log(negociacoes);
80            negociacoes.filter(novaNegociacao =>
81
82                !this._negociacoes.paraArray().some(negociacaoExistente =>
83                    novaNegociacao.equals(negociacaoExistente)))
84                .forEach(negociacao => this._negociacoes.adiciona(negociacao));
85
86            this._mensagem.texto = 'Negociações do período importadas com sucesso';
87        } catch (err) {
88            this._mensagem.texto = getExceptionMessage(err);
89        }
90    }
91
92    @bindEvent('click', '#botao-apaga')
93    async apaga() {
94
95        try {
96            const dao = await getNegociacaoDao();
97            await dao.apagaTodos();
98            this._negociacoes.esvazia();
99            this._mensagem.texto = 'Negociações apagadas com sucesso';
100        } catch (err) {
101            this._mensagem.texto = getExceptionMessage(err);
102        }
103    }
104}
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Run JavaScript Tests on LambdaTest Cloud Grid

Execute automation tests with Puppeteer on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)