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

  • SEARCH
  • Home
  • 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 7912187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:32:08+00:00 2026-06-03T13:32:08+00:00

I have a few functions that return a 1 if an error is encountered.

  • 0

I have a few functions that return a 1 if an error is encountered. Each function calls on a lower-level function, such that if the lower-level function returns a 1, the original function returns a 1 as well. Thus errors get passed up the chain in this way.

Here’s an highly abridged version of one of these functions:

if (low_level_function()) {
    [do stuff]
    return 1;
}
[do other stuff]
return 0;

Should I instead declare an error variable, assign the result of low_level_function() to it, and then use the error variable in the if() statement? In other words:

int error = low_level_function();
if (error) {
    [do stuff]
    return 1;
}
[do other stuff]
return 0;

Or is there yet another, better way of doing this? I’ve never coded to account for errors before, so my experience here is rather limited.

Edit: I’ve reformatted the functions to better convey the nature of my code.

  • 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-03T13:32:09+00:00Added an answer on June 3, 2026 at 1:32 pm

    I dont see the difference between the two approaches above.

    I would recomment using exception, much more cleaner approach. why the reinvent the wheel? You can either use standard exception or implement custome exception like

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a fairly simple python loop that calls a few functions, and writes
I have some python modules containing mostly functions and a few classes. Each one
I want to have a generic function for a few types such as long,
I have a bunch of Javascript functions that look like the following: function generateBusinessImage
I have a PHP function that returns an array. This is the output of
Lets say I have a few utility functions in file tests/utils/functions.js. I would like
I have defined a few different functions in my .bash_profile . I usually remember
I have written a few nearly identical functions, except for their names. For example:
I have a few issues with the following php functions (part of a bigger
I have to modify a few tables in one function. They must all succeed,

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.