$context->setLanguage( 'en' );
$context->setConfig( new MultiConfig( [
new HashConfig( [
- 'ShowHostnames' => true, 'ShowSQLErrors' => false,
- 'ShowExceptionDetails' => true, 'ShowDBErrorBacktrace' => true,
+ 'ShowHostnames' => true, 'ShowExceptionDetails' => true,
] ),
$context->getConfig()
] ) );
[ 'code' => 'existing-error', 'text' => 'existing error', 'module' => 'main' ],
[
'code' => 'internal_api_error_DBQueryError',
- 'text' => "[$reqId] Database query error.",
+ 'text' => "[$reqId] Exception caught: A database query error has occurred. " .
+ "This may indicate a bug in the software.",
]
],
'trace' => $dbtrace,
],
];
}
+
+ public function testPrinterParameterValidationError() {
+ $api = $this->getNonInternalApiMain( [
+ 'action' => 'query', 'meta' => 'siteinfo', 'format' => 'json', 'formatversion' => 'bogus',
+ ] );
+
+ ob_start();
+ $api->execute();
+ $txt = ob_get_clean();
+
+ // Test that the actual output is valid JSON, not just the format of the ApiResult.
+ $data = FormatJson::decode( $txt, true );
+ $this->assertInternalType( 'array', $data );
+ $this->assertArrayHasKey( 'error', $data );
+ $this->assertArrayHasKey( 'code', $data['error'] );
+ $this->assertSame( 'unknown_formatversion', $data['error']['code'] );
+ }
}