Error returns to applications (2024)

Error returns to applications

Except for the historic dbm, ndbm and hsearch interfaces, Berkeley DB does not use the global variable errno to return error values. The return values for all Berkeley DB functions are grouped into the following three categories:

0
A return value of 0 indicates that the operation was successful.
> 0
A return value that is greater than 0 indicates that there was a system error. The errno value returned by the system is returned by the function; for example, when a Berkeley DB function is unable to allocate memory, the return value from the function will be ENOMEM.
< 0
A return value that is less than 0 indicates a condition that was not a system failure, but was not an unqualified success, either. For example, a routine to retrieve a key/data pair from the database may return DB_NOTFOUND when the key/data pair does not appear in the database; as opposed to the value of 0, which would be returned if the key/data pair were found in the database.

All values returned by Berkeley DB functions are less than 0 in order to avoid conflict with possible values of errno. Specifically, Berkeley DB reserves all values from -30,800 to -30,999 to itself as possible error values. There are a few Berkeley DB interfaces where it is possible for an application function to be called by a Berkeley DB function and subsequently fail with an application-specific return. Such failure returns will be passed back to the function that originally called a Berkeley DB interface. To avoid ambiguity about the cause of the error, error values separate from the Berkeley DB error name space should be used.

Although possible error returns are specified by each individual function's manual page, there are a few error returns that deserve general mention:

DB_NOTFOUND and DB_KEYEMPTY

There are two special return values that are similar in meaning and that are returned in similar situations, and therefore might be confused: DB_NOTFOUND and DB_KEYEMPTY.

The DB_NOTFOUND error return indicates that the requested key/data pair did not exist in the database or that start-of- or end-of-file has been reached by a cursor.

The DB_KEYEMPTY error return indicates that the requested key/data pair logically exists but was never explicitly created by the application (the Recno and Queue access methods will automatically create key/data pairs under some circ*mstances; see DB->open() for more information), or that the requested key/data pair was deleted and never re-created. In addition, the Queue access method will return DB_KEYEMPTY for records that were created as part of a transaction that was later aborted and never re-created.

DB_KEYEXIST

The DB_KEYEXIST error return indicates the DB_NOOVERWRITE option was specified when inserting a key/data pair into the database and the key already exists in the database, or the DB_NODUPDATA option was specified and the key/data pair already exists in the data.

DB_LOCK_DEADLOCK

When multiple threads of control are modifying the database, there is normally the potential for deadlock. In Berkeley DB, deadlock is signified by an error return from the Berkeley DB function of the value DB_LOCK_DEADLOCK. Whenever a Berkeley DB function returns DB_LOCK_DEADLOCK, the enclosing transaction should be aborted.

Any Berkeley DB function that attempts to acquire locks can potentially return DB_LOCK_DEADLOCK. Practically speaking, the safest way to deal with applications that can deadlock is to anticipate a DB_LOCK_DEADLOCK return from any DB or DBC handle method call, or any DB_ENV handle method call that references a database, including the database's backing physical file.

DB_LOCK_NOTGRANTED

If a lock is requested from the DB_ENV->lock_get() or DB_ENV->lock_vec() methods with the DB_LOCK_NOWAIT flag specified, the method will return DB_LOCK_NOTGRANTED if the lock is not immediately available.

If the DB_TIME_NOTGRANTED flag is specified to the DB_ENV->set_flags() method, database calls timing out based on lock or transaction timeout values will return DB_LOCK_NOTGRANTED instead of DB_LOCK_DEADLOCK.

DB_RUNRECOVERY

There exists a class of errors that Berkeley DB considers fatal to an entire Berkeley DB environment. An example of this type of error is a corrupted database page. The only way to recover from these failures is to have all threads of control exit the Berkeley DB environment, run recovery of the environment, and re-enter Berkeley DB. (It is not strictly necessary that the processes exit, although that is the only way to recover system resources, such as file descriptors and memory, allocated by Berkeley DB.)

When this type of error is encountered, the error value DB_RUNRECOVERY is returned. This error can be returned by any Berkeley DB interface. Once DB_RUNRECOVERY is returned by any interface, it will be returned from all subsequent Berkeley DB calls made by any threads of control participating in the environment.

Applications can handle such fatal errors in one of two ways: first, by checking for DB_RUNRECOVERY as part of their normal Berkeley DB error return checking, similarly to DB_LOCK_DEADLOCK or any other error. Alternatively, applications can specify a fatal-error callback function using the DB_ENV->set_event_notify() method. Applications with no cleanup processing of their own should simply exit from the callback function.

DB_SECONDARY_BAD

The DB_SECONDARY_BAD error is returned if a secondary index has been corrupted. This may be the result of an application operating on related databases without first associating them.

Error returns to applications (2024)

FAQs

What does it mean when Matlab says not enough input arguments? ›

Accepted Answer

The error message is actually saying there aren't enough inputs to the function error_disL (not fit_disL). That happens because error_disL is defined to take 2 inputs, M and H0, but fminsearch is giving it 1 input, which is effectively the vector [M H0].

What is error not enough arguments specified? ›

"Not enough arguments" error is simply an indicative of the fact that you are calling some MATLAB/user-defined function with the wrong syntactical signature. You will need to pass correct number of inputs arguments to any function.

Why is my return statement not working in Java? ›

The missing return statement error is a compile-time error.

The main causes are: a return statement was simply omitted by mistake. the method doesn't return any value, but type void is not declared in the method signature.

How do I fix errors in MATLAB? ›

If you are unfamiliar with the problem, right-click the highlighted code. The first item in the context menu shows the suggested fix. Select the item to apply the fix. If multiple instances of a problem exist, MATLAB might offer to apply the suggested fix for all instances of the problem.

What does too many arguments mean in MATLAB? ›

1) Passing a function more input arguments than it expected to receive, perhaps by passing a list of inputs rather than a vector of inputs, or have tried to obtain two outputs from a function that only returns one. 2) You have multiple functions with the same name.

How do I fix not enough arguments for format string? ›

Q: How can I fix the 'not enough arguments for format string' error? A: To fix this error, ensure that for every placeholder in your format string, there is a corresponding argument provided. Double-check the number of %s , {} , or {0} in your string against the provided arguments.

What is argument error? ›

Argument errors are mistakes in logic or evidence that weaken or invalidate an argument.

What does invalid argument error mean? ›

The invalid argument error is a WebDriver error that occurs when the arguments passed to a command are either invalid or malformed. Invalid argument errors can be likened to TypeError s in JavaScript, in that they can occur for a great many APIs when the input value is not of the expected type or malformed in some way.

How to solve return error in Java? ›

There are two ways through which we can solve the error.
  1. By using void return type.
  2. By adding a return statement.

How to return a error in Java? ›

throw new Exception("error…"); The throw keyword in Java is used to throw an exception from a method or block of code when an error or exceptional condition occurs that the program cannot handle at runtime. The program flow is redirected to the closest catch block.

How to return list of errors in Java? ›

If you want to return a list of errors, then the objectyou return should contain a list, and you should populate that list with all the errors before returning. You should use a serializer like Jackson or ObjectMapper or Gson to convert the List<FeildError> to json string.

What is input argument in MATLAB? ›

An input argument default value can be any constant or expression that satisfies the size, class, and validation function requirements. Specifying a default value in an argument declaration makes the argument optional. MATLAB uses the default value when the argument is not included in the function call.

What is an input parameter in MATLAB? ›

The input parameter is a 1-by-1 string array (string scalar) that contains a 1-by-8 character vector. To make the string variable-size, click the second dimension. To specify that the second dimension is unbounded, select :Inf .

How do you find the number of input arguments in MATLAB? ›

numInputs = nargin( obj ) returns the number of input arguments that are required by the obj algorithm definition. This function is a System object™ extension of the general nargin function. nargin returns the number of input arguments specified in the call to the currently executing System object.

What is variable argument input in MATLAB? ›

varargin is an input variable in a function definition statement that enables the function to accept any number of input arguments. Specify varargin by using lowercase characters. After any explicitly declared inputs, include varargin as the last input argument.

Top Articles
Latest Posts
Article information

Author: Foster Heidenreich CPA

Last Updated:

Views: 6219

Rating: 4.6 / 5 (56 voted)

Reviews: 95% of readers found this page helpful

Author information

Name: Foster Heidenreich CPA

Birthday: 1995-01-14

Address: 55021 Usha Garden, North Larisa, DE 19209

Phone: +6812240846623

Job: Corporate Healthcare Strategist

Hobby: Singing, Listening to music, Rafting, LARPing, Gardening, Quilting, Rappelling

Introduction: My name is Foster Heidenreich CPA, I am a delightful, quaint, glorious, quaint, faithful, enchanting, fine person who loves writing and wants to share my knowledge and understanding with you.