Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8876919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:20:10+00:00 2026-06-14T19:20:10+00:00

In web app development I would like a consistent way to catch and report

  • 0

In web app development I would like a consistent way to catch and report error conditions. For example, a database update routine may detect a variety of error conditions and ideally I would like the application to capture them and report gracefully. The code below din’t work because retdiag is undefined when error is thrown…

function saveData(app,e) {
var db ;
var retdiag = ""; 
var lock = LockService.getPublicLock();
lock.waitLock(30000);
try {
// e.parameters has all the data fields from form
// re obtain the data to be updated
db = databaseLib.getDb();
var result = db.query({table: 'serviceUser',"idx":e.parameter.id});
if (result.getSize() !== 1) {
throw ("DB error - service user " + e.parameter.id);
}
//should be  one & only one
retdiag = 'Save Data Finished Ok'; 
}
catch (ex) {

retdiag= ex.message  // undefined!
}
finally {
lock.releaseLock();
return retdiag;
}
}

Is there a good or best practice for this is GAS?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T19:20:12+00:00Added an answer on June 14, 2026 at 7:20 pm

    To have a full error object, with message and stacktrace you have to build one, and not just throw a string. e.g. throw new Error("DB error ...");

    Now, a more “consistent” way I usually implement is to wrap all my client-side calls into a function that will treat any errors for me. e.g.

    function wrapper_(f,args) {
      try {
        return f.apply(this,args);
      } catch(err) {
        ;//log error here or send an email to yourself, etc
        throw err.message || err; //re-throw the message, so the client-side knows an error happend
      }
    }
    
    //real client side called functions get wrapped like this (just examples)
    function fileSelected(file,type) { return wrapper_(fileSelected_,[file,type]); }
    function loadSettings(id) { return wrapper_(loadSettings_,[id]); }
    
    function fileSelected_(file,type) {
      ; //do your thing
    }
    
    function loadSettings_(id) {
      ; //just examples
      throw new Error("DB error ...");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For Java web app development on GAE, I would like to add users androles
I'm very new to web app development and I thought I would start with
I would like to test my web app in other browsers. I have installed
I would like to connect my Android App to Remote MySQL database which has
I'm starting the development of a C#/ASP.net web app, within which I use the
I am using SQL Server with Entity Framework for a development of web app
I would like to log errors/informational and warning messages from within my web application
I am new to mobile development, but have some experience with web app development.
I'm completely new to Android development and would like to find out if the
I created an iphone app, and i'm currently in development of a web app

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.