ascii-chat
Binary v0.15.83-53-gb711d8720
Library lib/v0.3.2-701-gb711d8720
Video chat in your terminal
Loading...
Searching...
No Matches
src/web/common/errors.c
Go to the documentation of this file.
1#include "errors.h"
3#include <libplatform/thread.h>
5#include <ascii-chat/source_root.h>
6#include <emscripten/emscripten.h>
7
9static size_t browser_error_count;
10
13 errno_snapshot(thread_current_id(), browser_error_frames, ASCIICHAT_ERRNO_MAX_DEPTH);
14 browser_error_count = snapshot.copied;
15 return snapshot.total;
16}
17
18static const asciichat_error_context_t *browser_error_at(size_t index) {
19 return index < browser_error_count ? &browser_error_frames[index] : NULL;
20}
21
23 const asciichat_error_context_t *frame = browser_error_at(index);
24 return frame ? frame->code : ASCIICHAT_OK;
25}
26
27const char *browser_error_message(size_t index) {
28 const asciichat_error_context_t *frame = browser_error_at(index);
29 return frame ? frame->context_message : "";
30}
31
32const char *browser_error_file(size_t index) {
33 const asciichat_error_context_t *frame = browser_error_at(index);
34 return frame && frame->file ? extract_project_relative_path(frame->file, ASCIICHAT_OWNED_SOURCE_DIRS) : "";
35}
36
37const char *browser_error_full_file(size_t index) {
38#ifdef NDEBUG
39 (void)index;
40 return "";
41#else
42 const asciichat_error_context_t *frame = browser_error_at(index);
43 return frame && frame->file ? frame->file : "";
44#endif
45}
46
47const char *browser_error_function(size_t index) {
48 const asciichat_error_context_t *frame = browser_error_at(index);
49 return frame && frame->function ? frame->function : "";
50}
51
53 const asciichat_error_context_t *frame = browser_error_at(index);
54 return frame ? frame->line : 0;
55}
56
59 browser_error_count = 0;
60}
void errno_clear_all(void)
asciichat_errno_snapshot_t errno_snapshot(uint64_t id, asciichat_error_context_t *out, size_t capacity)
Synchronized per-thread pending error stacks and value snapshots. SET_ERRNO pushes,...
#define ASCIICHAT_ERRNO_MAX_DEPTH
@ ASCIICHAT_OK
Definition error_codes.h:46
const char * extract_project_relative_path(const char *file, const char *const *owned_dirs)
Extract a path relative to the source root embedded by CMake.
📂 Path Manipulation Utilities
static bool size_t index
Definition queries.h:8
int browser_error_code(size_t index)
const char * browser_error_message(size_t index)
const char * browser_error_function(size_t index)
void browser_error_dismiss(void)
size_t browser_error_snapshot(void)
const char * browser_error_full_file(size_t index)
const char * browser_error_file(size_t index)
int browser_error_line(size_t index)