How to infer error code from odooRPC answer integrated with angular 4

I have an Angular project integrated with odooRPC API. In the JSON response I get from odooRPC is below:

 error:{message: "Odoo Session Expired", code: 100, data: {,…}}
 code:100
 data:{,…}
 arguments:["Session expired"]
 debug : "Traceback (most recent call last):↵  raise http.SessionExpiredException("Session expired")↵SessionExpiredException: Session expired↵"
 exception_type:"internal_error"
 message :"Session expired"
 name : "odoo.http.SessionExpiredException"
 message : "Odoo Session Expired"
 id :null
 jsonrpc :"2.0"

this is the response from the OddoRPC call function on the network tab in chrome when an exception or error occurs, but my problem is that I cannot get all this answer when I catch this error. All I get is an error inside the debug parameter. Is there a way to get the value of "code" or "message"

Any help would be appreciated.

The code I use to call the odoodRPC function inside angular:

   return this.odooRPC.call('connect', 'getList',[],{}).catch((e: any) => {
         console.log(e);
        });

here getList is the function that I call from the Odoo server, and when I console it inside the catch block, all I get is the error message from the "debug" parameter.

+4
2

, Odoo jsonrpc angular, , ​​https://github.com/agenterp/angular5-odoo-jsonrpc. call , . odoorpc.service.ts

    errorObj.title = error.message;
    errorObj.message = error.data.debug.replace(/\n/g, "<br />");
    ...
    return Promise.reject(errorObj);

, API odoo Angular HttpClient.

+3

- ('is_affiliation_available') . int not recordset. .

+1

Source: https://habr.com/ru/post/1693500/


All Articles