[#fmt-system_error]
= xref:fmt.adoc[fmt]::system&lowbar;error
:relfileprefix: ../
:mrdocs:

Constructs `std&colon;&colon;system&lowbar;error` with a message formatted with `fmt&colon;&colon;format(fmt, args&period;&period;&period;)`&period; `error&lowbar;code` is a system error code as given by `errno`&period;

== Synopsis

Declared in `&lt;fmt&sol;format&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;typename&period;&period;&period; T&gt;
std::system&lowbar;error
system&lowbar;error(
    int error&lowbar;code,
    xref:fmt/format_string.adoc[format&lowbar;string&lt;T&period;&period;&period;&gt;] fmt,
    T&&&period;&period;&period; args);
----

== Description

*Example*&colon;

&sol;&sol; This throws std&colon;&colon;system&lowbar;error with the description &sol;&sol; cannot open file &apos;madeup&apos;&colon; No such file or directory &sol;&sol; or similar (system message may vary)&period; const char&ast; filename &equals; &quot;madeup&quot;&semi; FILE&ast; file &equals; fopen(filename, &quot;r&quot;)&semi; if (!file) throw fmt&colon;&colon;system&lowbar;error(errno, &quot;cannot open file &apos;&lcub;&rcub;&apos;&quot;, filename)&semi;

== Return Value

An exception type that includes an `error&lowbar;code` value&period;


[.small]#Created with https://www.mrdocs.com[MrDocs]#
