Skip to main content

NmiApiError

@nmi-agro/fdm-source


@nmi-agro/fdm-source / fdm-calculator/src / NmiApiError

Class: NmiApiError

Defined in: fdm-calculator/src/mineralization/errors.ts:29

Thrown when the NMI API returns a non-2xx HTTP response during a mineralization (nsupply) or DYNA calculation request.

Example

try {
await getNSupply(fdm, input)
} catch (err) {
if (err instanceof NmiApiError && err.status === 422) {
// Handle missing soil data
}
}

Common status codes:

  • 400 — Invalid request (e.g. duplicate year in rotation, missing b_lu)
  • 401 / 403 — API key missing or expired
  • 422 — Insufficient soil/field data to run the model
  • 503 — NMI API temporarily unavailable

Extends

  • Error

Constructors

Constructor

new NmiApiError(status, message): NmiApiError

Defined in: fdm-calculator/src/mineralization/errors.ts:39

Parameters

status

number

HTTP status code from the NMI API response

message

string

Dutch-language user-facing error description

Returns

NmiApiError

Overrides

Error.constructor

Properties

cause?

optional cause?: unknown

Defined in: node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.error.d.ts:24

Inherited from

Error.cause


message

message: string

Defined in: node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1075

Inherited from

Error.message


name

name: string

Defined in: node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1074

Inherited from

Error.name


stack?

optional stack?: string

Defined in: node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076

Inherited from

Error.stack


status

readonly status: number

Defined in: fdm-calculator/src/mineralization/errors.ts:33

The HTTP status code returned by the NMI API.

Methods

isError()

static isError(error): error is Error

Defined in: node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.esnext.error.d.ts:21

Indicates whether the argument provided is a built-in Error instance or not.

Parameters

error

unknown

Returns

error is Error

Inherited from

Error.isError