( field: string, reason: string, accepted?: unknown, kind: 'flag' | 'field' = 'flag', )
| 227 | * flag that doesn't exist in the CLI surface. |
| 228 | */ |
| 229 | export function localValidationError( |
| 230 | field: string, |
| 231 | reason: string, |
| 232 | accepted?: unknown, |
| 233 | kind: 'flag' | 'field' = 'flag', |
| 234 | ): ApiError { |
| 235 | const subject = |
| 236 | kind === 'flag' |
| 237 | ? `Flag \`--${field.replace(/[A-Z]/g, ch => `-${ch.toLowerCase()}`)}\`` |
| 238 | : `Field \`${field}\``; |
| 239 | return ApiError.fromEnvelope({ |
| 240 | error: { |
| 241 | code: 'VALIDATION_ERROR', |
| 242 | message: 'Invalid request.', |
| 243 | nextAction: `${subject} is invalid: ${reason}.`, |
| 244 | requestId: 'local', |
| 245 | details: accepted === undefined ? { field, reason } : { field, reason, accepted }, |
| 246 | }, |
| 247 | }); |
| 248 | } |
| 249 | |
| 250 | /** |
| 251 | * Network/transport failure not associated with a server envelope. Treated |
no test coverage detected