dart - pass an errormessage from server to client -


I defined some classes to query the database.

  class SqlGetData {ConnectionPool pool; & Lt; String & gt; Rows; SQLGetData (this.pool); Future & lt; List & lt; String & gt; & Gt; Run (string sQuery) {rows = new list & lt; String & gt; (); Read back data (sQuery). Then ((_) {return rows;}); } Future reading data (string sQuery) {return pool.query (sQuery). Then ((result) {return result.forEach ((line) {string s = JSON.encode (line); rows.ed (;)}})}); }}  

Which I like it to:

  var sql = new SqlGetData (pool); Sql.run ('name of first name, last name is from person where id =' + s1). Then ((rows) {some code here to process data}};  

If the database is not running, I get an error at return pool.query at readData , which I can capture Wish and pass the client in some error message to prevent the server from dying to ... capture ... How can I code and how? My problem is that I have to return futures, which is still difficult for me to understand.

Look at this article (if you have not already).

= & Gt; doErrorHandling ()). CatchError ((e) = & gt; doErrorHandling ());


Comments