NmiApiError
@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, missingb_lu)401/403— API key missing or expired422— Insufficient soil/field data to run the model503— 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?
optionalcause?: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?
optionalstack?:string
Defined in: node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076
Inherited from
Error.stack
status
readonlystatus:number
Defined in: fdm-calculator/src/mineralization/errors.ts:33
The HTTP status code returned by the NMI API.
Methods
isError()
staticisError(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