mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 15:19:35 +02:00
errors: add HTTP status codes
This commit is contained in:
parent
b144dd5358
commit
b57c212bb5
1 changed files with 56 additions and 28 deletions
|
@ -10,42 +10,50 @@ const byErrorCode = Object.assign(Object.create(null), {
|
||||||
AUTH: {
|
AUTH: {
|
||||||
isClient: true,
|
isClient: true,
|
||||||
code: ACCESS_DENIED,
|
code: ACCESS_DENIED,
|
||||||
message: 'invalid or missing authentication data'
|
message: 'invalid or missing authentication data',
|
||||||
|
statusCode: 401
|
||||||
},
|
},
|
||||||
R0001: {
|
R0001: {
|
||||||
isClient: true,
|
isClient: true,
|
||||||
code: INVALID_REQUEST,
|
code: INVALID_REQUEST,
|
||||||
message: 'unknown method'
|
message: 'unknown method',
|
||||||
|
statusCode: 400
|
||||||
},
|
},
|
||||||
R0002: {
|
R0002: {
|
||||||
isClient: true,
|
isClient: true,
|
||||||
code: INVALID_REQUEST,
|
code: INVALID_REQUEST,
|
||||||
message: 'invalid or missing request parameters'
|
message: 'invalid or missing request parameters',
|
||||||
|
statusCode: 400
|
||||||
},
|
},
|
||||||
R0007: {
|
R0007: {
|
||||||
isServer: true,
|
isServer: true,
|
||||||
code: SERVER_ERROR,
|
code: SERVER_ERROR,
|
||||||
message: 'internal communication error'
|
message: 'internal communication error',
|
||||||
|
statusCode: 500
|
||||||
},
|
},
|
||||||
R5000: {
|
R5000: {
|
||||||
isClient: true,
|
isClient: true,
|
||||||
code: ACCESS_DENIED,
|
code: ACCESS_DENIED,
|
||||||
message: 'access denied'
|
message: 'access denied',
|
||||||
|
statusCode: 401
|
||||||
},
|
},
|
||||||
S1: {
|
S1: {
|
||||||
isServer: true,
|
isServer: true,
|
||||||
code: SERVER_ERROR,
|
code: SERVER_ERROR,
|
||||||
message: 'journeys search: a connection to the backend server couldn\'t be established'
|
message: 'journeys search: a connection to the backend server couldn\'t be established',
|
||||||
|
statusCode: 503
|
||||||
},
|
},
|
||||||
LOCATION: {
|
LOCATION: {
|
||||||
isClient: true,
|
isClient: true,
|
||||||
code: INVALID_REQUEST,
|
code: INVALID_REQUEST,
|
||||||
message: 'location/stop not found'
|
message: 'location/stop not found',
|
||||||
|
statusCode: 400
|
||||||
},
|
},
|
||||||
H390: {
|
H390: {
|
||||||
isClient: true,
|
isClient: true,
|
||||||
code: INVALID_REQUEST,
|
code: INVALID_REQUEST,
|
||||||
message: 'journeys search: departure/arrival station replaced'
|
message: 'journeys search: departure/arrival station replaced',
|
||||||
|
statusCode: 400
|
||||||
},
|
},
|
||||||
H410: {
|
H410: {
|
||||||
// todo: or is it a client error?
|
// todo: or is it a client error?
|
||||||
|
@ -57,37 +65,44 @@ const byErrorCode = Object.assign(Object.create(null), {
|
||||||
H455: {
|
H455: {
|
||||||
isClient: true,
|
isClient: true,
|
||||||
code: INVALID_REQUEST,
|
code: INVALID_REQUEST,
|
||||||
message: 'journeys search: prolonged stop'
|
message: 'journeys search: prolonged stop',
|
||||||
|
statusCode: 400
|
||||||
},
|
},
|
||||||
H460: {
|
H460: {
|
||||||
isClient: true,
|
isClient: true,
|
||||||
code: INVALID_REQUEST,
|
code: INVALID_REQUEST,
|
||||||
message: 'journeys search: stop(s) passed multiple times'
|
message: 'journeys search: stop(s) passed multiple times',
|
||||||
|
statusCode: 400
|
||||||
},
|
},
|
||||||
H500: {
|
H500: {
|
||||||
isClient: true,
|
isClient: true,
|
||||||
code: INVALID_REQUEST,
|
code: INVALID_REQUEST,
|
||||||
message: 'journeys search: too many trains, connection is not complete'
|
message: 'journeys search: too many trains, connection is not complete',
|
||||||
|
statusCode: 400
|
||||||
},
|
},
|
||||||
H890: {
|
H890: {
|
||||||
isClient: true,
|
isClient: true,
|
||||||
code: NOT_FOUND,
|
code: NOT_FOUND,
|
||||||
message: 'journeys search unsuccessful'
|
message: 'journeys search unsuccessful',
|
||||||
|
statusCode: 404
|
||||||
},
|
},
|
||||||
H891: {
|
H891: {
|
||||||
isClient: true,
|
isClient: true,
|
||||||
code: NOT_FOUND,
|
code: NOT_FOUND,
|
||||||
message: 'journeys search: no route found, try with an intermediate stations'
|
message: 'journeys search: no route found, try with an intermediate stations',
|
||||||
|
statusCode: 404
|
||||||
},
|
},
|
||||||
H892: {
|
H892: {
|
||||||
isClient: true,
|
isClient: true,
|
||||||
code: INVALID_REQUEST,
|
code: INVALID_REQUEST,
|
||||||
message: 'journeys search: query too complex, try less intermediate stations'
|
message: 'journeys search: query too complex, try less intermediate stations',
|
||||||
|
statusCode: 400
|
||||||
},
|
},
|
||||||
H895: {
|
H895: {
|
||||||
isClient: true,
|
isClient: true,
|
||||||
code: INVALID_REQUEST,
|
code: INVALID_REQUEST,
|
||||||
message: 'journeys search: departure & arrival are too near'
|
message: 'journeys search: departure & arrival are too near',
|
||||||
|
statusCode: 400
|
||||||
},
|
},
|
||||||
H899: {
|
H899: {
|
||||||
// todo: or is it a client error?
|
// todo: or is it a client error?
|
||||||
|
@ -106,67 +121,80 @@ const byErrorCode = Object.assign(Object.create(null), {
|
||||||
H9220: {
|
H9220: {
|
||||||
isClient: true,
|
isClient: true,
|
||||||
code: NOT_FOUND,
|
code: NOT_FOUND,
|
||||||
message: 'journeys search: no stations found close to the address'
|
message: 'journeys search: no stations found close to the address',
|
||||||
|
statusCode: 400
|
||||||
},
|
},
|
||||||
H9230: {
|
H9230: {
|
||||||
isServer: true,
|
isServer: true,
|
||||||
code: SERVER_ERROR,
|
code: SERVER_ERROR,
|
||||||
message: 'journeys search: an internal error occured'
|
message: 'journeys search: an internal error occured',
|
||||||
|
statusCode: 500
|
||||||
},
|
},
|
||||||
H9240: {
|
H9240: {
|
||||||
isClient: true,
|
isClient: true,
|
||||||
code: NOT_FOUND,
|
code: NOT_FOUND,
|
||||||
message: 'journeys search unsuccessful'
|
message: 'journeys search unsuccessful',
|
||||||
|
statusCode: 404
|
||||||
},
|
},
|
||||||
H9250: {
|
H9250: {
|
||||||
isServer: true,
|
isServer: true,
|
||||||
code: SERVER_ERROR,
|
code: SERVER_ERROR,
|
||||||
message: 'journeys search: leg query interrupted'
|
message: 'journeys search: leg query interrupted',
|
||||||
|
statusCode: 500
|
||||||
},
|
},
|
||||||
H9260: {
|
H9260: {
|
||||||
isClient: true,
|
isClient: true,
|
||||||
code: INVALID_REQUEST,
|
code: INVALID_REQUEST,
|
||||||
message: 'journeys search: unknown departure station'
|
message: 'journeys search: unknown departure station',
|
||||||
|
statusCode: 400
|
||||||
},
|
},
|
||||||
H9280: {
|
H9280: {
|
||||||
isClient: true,
|
isClient: true,
|
||||||
code: INVALID_REQUEST,
|
code: INVALID_REQUEST,
|
||||||
message: 'journeys search: unknown intermediate station'
|
message: 'journeys search: unknown intermediate station',
|
||||||
|
statusCode: 400
|
||||||
},
|
},
|
||||||
H9300: {
|
H9300: {
|
||||||
isClient: true,
|
isClient: true,
|
||||||
code: INVALID_REQUEST,
|
code: INVALID_REQUEST,
|
||||||
message: 'journeys search: unknown arrival station'
|
message: 'journeys search: unknown arrival station',
|
||||||
|
statusCode: 400
|
||||||
},
|
},
|
||||||
H9320: {
|
H9320: {
|
||||||
isClient: true,
|
isClient: true,
|
||||||
code: INVALID_REQUEST,
|
code: INVALID_REQUEST,
|
||||||
message: 'journeys search: the input is incorrect or incomplete'
|
message: 'journeys search: the input is incorrect or incomplete',
|
||||||
|
statusCode: 400
|
||||||
},
|
},
|
||||||
H9360: {
|
H9360: {
|
||||||
isClient: true,
|
isClient: true,
|
||||||
code: INVALID_REQUEST,
|
code: INVALID_REQUEST,
|
||||||
message: 'journeys search: error in a data field'
|
message: 'journeys search: error in a data field',
|
||||||
|
statusCode: 400
|
||||||
},
|
},
|
||||||
H9380: {
|
H9380: {
|
||||||
isClient: true,
|
isClient: true,
|
||||||
code: INVALID_REQUEST,
|
code: INVALID_REQUEST,
|
||||||
message: 'journeys search: departure/arrival/intermediate station defined more than once'
|
message: 'journeys search: departure/arrival/intermediate station defined more than once',
|
||||||
|
statusCode: 400
|
||||||
},
|
},
|
||||||
SQ001: {
|
SQ001: {
|
||||||
isServer: true,
|
isServer: true,
|
||||||
code: SERVER_ERROR,
|
code: SERVER_ERROR,
|
||||||
message: 'no departures/arrivals data available'
|
message: 'no departures/arrivals data available',
|
||||||
|
statusCode: 503
|
||||||
},
|
},
|
||||||
SQ005: {
|
SQ005: {
|
||||||
isClient: true,
|
isClient: true,
|
||||||
code: NOT_FOUND,
|
code: NOT_FOUND,
|
||||||
message: 'no trips found'
|
message: 'no trips found',
|
||||||
|
statusCode: 404
|
||||||
},
|
},
|
||||||
TI001: {
|
TI001: {
|
||||||
isServer: true,
|
isServer: true,
|
||||||
code: SERVER_ERROR,
|
code: SERVER_ERROR,
|
||||||
message: 'no trip info available'
|
message: 'no trip info available',
|
||||||
|
statusCode: 503
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue