| Previous | Next |
| ERROR_INVALID_ORDINAL | ERROR_INVALID_FLAG_NUMBER |
ERROR_ALREADY_EXISTS
The requested object already exists
ERROR_ALREADY_EXISTS commonly accompanies APIs that can open or create named files, directories, synchronization objects, or other resources. Some APIs still return a usable handle and use this code to describe the creation outcome.
What to check
- Read the API contract to determine whether the returned handle remains valid.
- Compare this code with
ERROR_FILE_EXISTS, because APIs use them differently. - Verify whether reusing an existing object is safe for the caller.
- Check for races between an existence test and the create operation.
How to handle it
Use an atomic create-or-open API and branch on the reported outcome. Do not delete an existing object unless ownership and lifecycle rules explicitly permit it.
References
Looking for a different code? Search another status or error code.