// The MIT License (MIT)
//
// Copyright (C) 2026 Scott Duensing
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.

// basErrors.h -- DVX BASIC runtime error code constants

#ifndef DVXBASIC_BASERRORS_H
#define DVXBASIC_BASERRORS_H

// Runtime error numbers reported via runtimeError() and stored in the VM
// errorNumber field. Values are the classic Microsoft/QuickBASIC ERR codes
// and are the single source of truth for these numbers. Ordered by numeric
// value to match the codebase's ABI-ordered constant style (see opcodes.h).
//
// Note: BAS_ERR_SUBSCRIPT_RANGE (9) is overloaded. In addition to genuine
// subscript-out-of-range failures, the VM also uses code 9 for internal
// "invalid variable/field/dimension index" and "outside form context"
// conditions, preserving the historical numeric value at those sites.

#define BAS_ERR_NEXT_WITHOUT_FOR   1
#define BAS_ERR_OUT_OF_DATA        4
#define BAS_ERR_ILLEGAL_FUNC_CALL  5
#define BAS_ERR_OVERFLOW           6
#define BAS_ERR_OUT_OF_MEMORY      7
#define BAS_ERR_SUBSCRIPT_RANGE    9
#define BAS_ERR_DIV_BY_ZERO        11
#define BAS_ERR_TYPE_MISMATCH      13
#define BAS_ERR_RESUME_WITHOUT_ERR 20
#define BAS_ERR_FOR_NESTING        26
#define BAS_ERR_BAD_OPCODE         51
#define BAS_ERR_BAD_FILE_NUM       52
#define BAS_ERR_FILE_NOT_FOUND     53
#define BAS_ERR_BAD_FILE_MODE      54
#define BAS_ERR_FILE_EXISTS        58
#define BAS_ERR_BAD_RECORD_LEN     59
#define BAS_ERR_TOO_MANY_FILES     67
#define BAS_ERR_PATH_FILE_ACCESS   75
#define BAS_ERR_PATH_NOT_FOUND     76
#define BAS_ERR_EXTERNAL_NOT_FOUND 453

#endif
