标签: error-handling

Delphi中的AccessViolationException - 不可能(检查它,难以置信......)

德尔福XE.Windows 7的.

有一个功能(请参阅下面的代码)或I:=0导致大项目中的AV错误.在新项目中没有相同功能的错误!我删除了大项目中的所有内容,我只留下了一个按钮和该功能.它仍然会导致错误......

带错误的一行:

if ISAeroEnabled then // this line is a cause
       i:=0;         // or this line
Run Code Online (Sandbox Code Playgroud)

我在任何地方设置了断点(我检查了整个函数,我在EACH LINE上设置了断点- >函数中没有错误),调试器显示错误在于i:=0;

如果删除一个功能(并离开i:=0;) - > 一切都好!

错误消息: First chance exception at $747FB727. Exception class EAccessViolation with message 'Access violation at address 004AE5AF in module 'MngProject.exe'. Write of address 0017FFF8'. Process MngProject.exe (4980)

为什么它在新项目中有效但在我的项目中却没有?

这是整个项目:http://www.2shared.com/file/UP22Om4j/Bug.html

代码:

unit MainFormModule;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  StdCtrls;
type
  TMainForm = …
Run Code Online (Sandbox Code Playgroud)

delphi error-handling access-violation

-3
推荐指数
1
解决办法
2407
查看次数

'struct'在参数列表中声明

这是我的头文件,它包含在另一个文件中但尚未使用:

#define ksm_read 0X01
#define ksm_rdwr 0x00

struct ksm_info_t {
    uint ksmsz; //size of shared mem
    int cpid;   //pid of the creator
    int mpid;   //pid of the last modifier
    uint attached_nr; //number of attached processes
    uint atime; //last attached time
    uint dtime; //last deattach time
    uint total_shrg_nr; //total number of existing shared regions
    uint total_shpg_nr; //total number of existing shared pages
};

int ksmget(char* name, uint size);
int ksmattach(int hd, int flag);
int ksmdetach(int hd);
int ksminfo(int hd, struct ksminfo_t* …
Run Code Online (Sandbox Code Playgroud)

c compiler-construction error-handling struct header

-3
推荐指数
1
解决办法
2750
查看次数

TypeError:'int'对象不可调用:Quadratic

(在没有导入的二次方程中找到x的值.)每当我运行程序时,Python停在discriminant = (b ** 2) - 4(a * c)并显示TypeError:'int'对象不可调用.怎么了?

#------SquareRootDefinition---------#
def Square_Root(n, x):
if n > 0:
    y = (x + n/x) / 2
    while x != y:
        x = y
        return Square_Root(n, x)
    else:
        if abs(10 ** -7) > abs(n - x ** 2):
            return y
elif n == 0:
    return 0
else:
    return str(int(-n)) + "i"

#----------Quadratic Equation--------------#

a = input("Enter coefficient a: ")
while a == 0:
    print "a must not be equal to 0." …
Run Code Online (Sandbox Code Playgroud)

python error-handling quadratic python-2.7

-3
推荐指数
2
解决办法
672
查看次数

注意:未定义的变量

我有这个警告的问题

注意:未定义的变量:第35行的C:\ wamp\www\android_connect\cara1.php中的T_Person

警告:在第35行的C:\ wamp\www\android_connect\cara1.php中为foreach()提供的参数无效

第35行是foreach($ T_Person为$ Person)

我不明白这是错误的这是我的PHP代码:

<!DOCTYPE html>
<html>
<head>
<title>Daftar Buku</title>
<!--Bagian CSS untuk Styling Tabel-->
<style type="text/css">
      table, th, td
      {
           border: 1px solid black;
      }
</style>
</head>
<body>

<h3>Daftar Buku Terbaru</h3>
<?php

$Person = new SimpleXMLElement('contoh.xml', null, true);


echo "
<table>
<tr>
<th>First name</th>
<th>middle name</th>
<th>Alias</th>
<th>Gender</th>
<th>City</th>
<th>Person ID</th>
</tr>

";

 foreach($T_Person as $Person)
 {
    echo "
 <tr>
 <td width='200'>{$Person->First_name}</td>
 <td width='200'>{$Person->Middle_Name_Person}</td>
 <td width='130'>{$Person->Alias_Person}</td>
 <td width='80'>\${$Person->Gender_Person}</td>
 <td width='130'>{$Person->CityBirth_Person}</td>
 <td width='130'>{$Person['Person ID']}</td>
 </tr> …
Run Code Online (Sandbox Code Playgroud)

php error-handling

-3
推荐指数
1
解决办法
189
查看次数

c ++ - try块后是否需要立即写入catch块?

我的编译器给出了以下代码的错误:

#include <iostream>
#include <stdexcept>

using namespace std;


void test()
{
     throw runtime_error("Error");
}

int main()
{
     try
     {
          test();
     }

     for (int i = 0; i < 10; i++)
     {

     }

     catch (exception& e)
     {
          cout << e.what();
     }
}
Run Code Online (Sandbox Code Playgroud)

它说"错误:预期'捕获'之前'('令牌',它指的是for循环初始化中的'(').

在try块之后我是否必须立即编写catch块?我认为如果在try块中抛出一个错误,程序将冒出来,直到它找到一个合适的catch块.为什么这不适用于此?

c++ error-handling exception-handling try-catch c++11

-3
推荐指数
1
解决办法
538
查看次数

为什么 Go 中的错误可以为 null?

Go 中的错误可能为零。编译如下:

   var err error
   err = nil 
   err = errors.New("hello")
Run Code Online (Sandbox Code Playgroud)

然而错误是值,并且值类型在 Go 中不可为空。

看了一下error,是一个普通的界面:

type error interface {
    Error() string
}
Run Code Online (Sandbox Code Playgroud)

由该结构体实现:

type errorString struct {
    s string
}
Run Code Online (Sandbox Code Playgroud)

这里没有指点。有一种方法需要一个指针接收器,

func (e *errorString) Error() string {
    return e.s
}
Run Code Online (Sandbox Code Playgroud)

但这并不能解释为什么它error表现为指针而不是值。

errors.New()确实返回一个指针,

func New(text string) error {
    return &errorString{text}
}
Run Code Online (Sandbox Code Playgroud)

这使得我上面的第三行代码更加令人费解——我们将 的结果分配New给一个值变量。

这是如何运作的?

error-handling null interface go

-3
推荐指数
1
解决办法
473
查看次数

相同的代码,一个有效,一个无效。有什么不同?

我是一名初学者程序员,这是我第一次发帖。我目前正在用 C++ 编写一个贪吃蛇游戏。游戏的大部分内容并不难实现,但当涉及到蛇的尾巴时,整个程序就崩溃了。我花了大约 2 个小时试图找出问题所在,然后我决定尝试重写有问题的代码。据我了解,我没有改变任何事情,但现在它有效了。有人可以向我解释一下发生了什么变化吗?这是代码,注释的代码无法正常工作,而其他代码则可以正常工作:

   else { 
            bool eCoada = false;
            for (int s = 0; s <= ntail; s++)
            {
                if (tail[s].height == j && tail[s].width == k)
                { eCoada = true; break; }

            }
            if (eCoada == false)  cout << " ";
            else cout << "o";
        }
    /*  else  {
            bool eCoada = false;
        for (int s = 0;s <= ntail; s++)
        {
            if (tail[s].height==j &&  k==tail[s].width==k)
            { eCoada = true; break; }
            if (eCoada==false)  cout << " …
Run Code Online (Sandbox Code Playgroud)

c++ error-handling function object

-3
推荐指数
1
解决办法
85
查看次数

使用if(condition)返回时的C++内存错误:难以置信

今天我写了一些有趣的代码,将整数转换为罗马数字.整个运行代码在这里:

#include <iostream>
#include <map>
#include <string>

using namespace std;

string arabic2roman(int i){
//if(i==0) return "ZERO";

map<int, string> m;
m.insert(pair<int,string>(0,"ZERO"));
m.insert(pair<int,string>(1,"I"));
m.insert(pair<int,string>(4,"IV"));
m.insert(pair<int,string>(5,"V"));
m.insert(pair<int,string>(9,"IX"));
m.insert(pair<int,string>(10,"X"));
m.insert(pair<int,string>(40,"XL"));
m.insert(pair<int,string>(50,"L"));
m.insert(pair<int,string>(90,"XC"));
m.insert(pair<int,string>(100,"C"));
m.insert(pair<int,string>(400,"CD"));
m.insert(pair<int,string>(500,"D"));
m.insert(pair<int,string>(900,"CM"));
m.insert(pair<int,string>(1000,"M"));

string roman;
map<int,string>::iterator iter;
for(iter=m.end();iter !=m.begin();iter--){
    while(i >=iter->first){
        roman+=iter->second;
        i-=iter->first;
    }
}
return roman;
}

int main(){
    int test=12345;
    cout << arabic2roman(test) << endl;
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

这段代码现在在我的Xcode 4.6.2上工作正常.但是如果在if(i == 0)之前的第8行中删除"//",则返回"ZERO",在Xcode 4.6.2上,程序无休止地运行.任何人都能解释一下吗?谢谢!

c++ error-handling if-statement return

-4
推荐指数
2
解决办法
165
查看次数

错误我不明白

我在 Python 3.5 中产生了这个错误:

回溯(最近一次调用):文件“C:\Users\Owner\AppData\Local\Programs\Python\Python35\lib\shelve.py”,第 111 行,在 __getitem__ value = self.cache[key] KeyError: ' P4_蔬菜'

在处理上述异常的过程中,又发生了一个异常:

回溯(最近一次调用):文件“C:\Users\Owner\Documents\Python\Allotment\allotment.py”,第 217 行,在 main_program() 文件“C:\Users\Owner\Documents\Python\Allotment\ allotment.py", line 195, in main_program main_program() 文件 "C:\Users\Owner\Documents\Python\Allotment\allotment.py", line 49, in main_program print("Plot 4 - ", s["P4_vegetables "]) 文件 "C:\Users\Owner\AppData\Local\Programs\Python\Python35\lib\shelve.py",第 113 行,在 __getitem__ f = BytesIO(self.dict[key.encode(self.keyencoding) ]) 文件“C:\Users\Owner\AppData\Local\Programs\Python\Python35\lib\dbm\dumb.py”,第 141 行,在 __getitem__ pos, siz = self._index[key] # 可能会引发 KeyError KeyError : b'P4_vegetables'

error-handling python-3.x

-4
推荐指数
1
解决办法
1947
查看次数

优雅的方式在没有goto的情况下在C++中执行多个依赖错误检查,而且没有提前返回?

假设我想连续调用四个函数,这些函数在我的某个对象上运行.如果其中任何一个失败,我想返回FAILURE而不调用其他人,我想要返回SUCCESSiff所有这些都成功完成.

通常,我会做这样的事情:

if(function_zero(&myMutableObject) == SUCCESS)
{
    return FAILURE;
}
if(function_one(&myMutableObject) == SUCCESS)
{
    return FAILURE;
}
if(function_two(&myMutableObject) == SUCCESS)
{
    return FAILURE;
}
if(function_three(&myMutableObject) == SUCCESS)
{
    return FAILURE;
}

return SUCCESS;
Run Code Online (Sandbox Code Playgroud)

或者,如果我需要做一些清理:

if(function_zero(&myMutableObject) == SUCCESS)
{
    status = FAILURE;
    goto cleanup;
}
if(function_one(&myMutableObject) == SUCCESS)
{
    status = FAILURE;
    goto cleanup;
}
if(function_two(&myMutableObject) == SUCCESS)
{
    status = FAILURE;
    goto cleanup;
}
if(function_three(&myMutableObject) == SUCCESS)
{
    status = FAILURE;
    goto cleanup;
}

cleanup:
// necessary …
Run Code Online (Sandbox Code Playgroud)

c++ error-handling goto

-5
推荐指数
2
解决办法
528
查看次数