Skip to content

@my-swu/simulator-client


@my-swu/simulator-client / EngineHttpErrorOptions

Interface: EngineHttpErrorOptions

Defined in: packages/ts-sdk/src/internal/errors.ts:23

Context captured for one non-2xx HTTP response.

These fields make HTTP failures safe to render or log without parsing the original Response object again.

Example:

ts
import type { EngineHttpErrorOptions } from '@my-swu/simulator-client'

const 
engineHttpErrorOptions
: EngineHttpErrorOptions = {
status
: 404,
code
: 'match_not_found',
method
: 'GET',
url
: 'http://127.0.0.1:4000/api/matches/missing',
}
console
.
log
(
engineHttpErrorOptions
)

Example

ts
import type { EngineHttpErrorOptions } from '@my-swu/simulator-client'

const notFoundOptions: EngineHttpErrorOptions = {
  status: 404,
  code: 'match_not_found',
  method: 'GET',
  url: 'http://127.0.0.1:4000/api/matches/missing',
}

console.log(notFoundOptions.status)

See

https://simulator-sdk.my-swu.com/guide/errors

Properties

code?

Example:

ts
import type { EngineHttpErrorOptions } from '@my-swu/simulator-client'

const 
engineHttpErrorOptions
: EngineHttpErrorOptions = {
status
: 404,
code
: 'match_not_found',
method
: 'GET',
url
: 'http://127.0.0.1:4000/api/matches/missing',
} const {
code
:
errorCode
} =
engineHttpErrorOptions
console
.
log
(
errorCode
)

optional code?: string

Defined in: packages/ts-sdk/src/internal/errors.ts:27

Engine error code when the response body matched api-error-response.


method?

Example:

ts
import type { EngineHttpErrorOptions } from '@my-swu/simulator-client'

const 
engineHttpErrorOptions
: EngineHttpErrorOptions = {
status
: 404,
code
: 'match_not_found',
method
: 'GET',
url
: 'http://127.0.0.1:4000/api/matches/missing',
} const {
method
:
httpMethod
} =
engineHttpErrorOptions
console
.
log
(
httpMethod
)

optional method?: string

Defined in: packages/ts-sdk/src/internal/errors.ts:31

HTTP method used for the failed request.


payload?

Example:

ts
import type { EngineHttpErrorOptions } from '@my-swu/simulator-client'

const 
engineHttpErrorOptions
: EngineHttpErrorOptions = {
status
: 404,
code
: 'match_not_found',
method
: 'GET',
url
: 'http://127.0.0.1:4000/api/matches/missing',
} const {
payload
} =
engineHttpErrorOptions
console
.
log
(
payload
)

optional payload?: unknown

Defined in: packages/ts-sdk/src/internal/errors.ts:35

Parsed JSON payload when an error body was JSON but not a valid engine error.


responseText?

Example:

ts
import type { EngineHttpErrorOptions } from '@my-swu/simulator-client'

const 
engineHttpErrorOptions
: EngineHttpErrorOptions = {
status
: 404,
code
: 'match_not_found',
method
: 'GET',
url
: 'http://127.0.0.1:4000/api/matches/missing',
} const {
responseText
} =
engineHttpErrorOptions
console
.
log
(
responseText
)

optional responseText?: string

Defined in: packages/ts-sdk/src/internal/errors.ts:39

Raw response text when the server returned an error body.


status

Example:

ts
import type { EngineHttpErrorOptions } from '@my-swu/simulator-client'

const 
engineHttpErrorOptions
: EngineHttpErrorOptions = {
status
: 404,
code
: 'match_not_found',
method
: 'GET',
url
: 'http://127.0.0.1:4000/api/matches/missing',
} const {
status
:
healthStatus
} =
engineHttpErrorOptions
console
.
log
(
healthStatus
)

status: number

Defined in: packages/ts-sdk/src/internal/errors.ts:43

HTTP response status.


url?

Example:

ts
import type { EngineHttpErrorOptions } from '@my-swu/simulator-client'

const 
engineHttpErrorOptions
: EngineHttpErrorOptions = {
status
: 404,
code
: 'match_not_found',
method
: 'GET',
url
: 'http://127.0.0.1:4000/api/matches/missing',
} const {
url
:
requestUrl
} =
engineHttpErrorOptions
console
.
log
(
requestUrl
)

optional url?: string

Defined in: packages/ts-sdk/src/internal/errors.ts:47

Fully resolved request URL.

Released under the MIT License.